notification service and user management improvements
This commit is contained in:
@ -17,6 +17,8 @@ namespace Oqtane.Repository
|
||||
public virtual DbSet<Permission> Permission { get; set; }
|
||||
public virtual DbSet<Setting> Setting { get; set; }
|
||||
public virtual DbSet<Log> Log { get; set; }
|
||||
public virtual DbSet<Notification> Notification { get; set; }
|
||||
public virtual DbSet<Folder> Folder { get; set; }
|
||||
|
||||
public TenantDBContext(ITenantResolver TenantResolver, IHttpContextAccessor accessor) : base(TenantResolver, accessor)
|
||||
{
|
||||
|
70
Oqtane.Server/Repository/FolderRepository.cs
Normal file
70
Oqtane.Server/Repository/FolderRepository.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class FolderRepository : IFolderRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
private readonly IPermissionRepository Permissions;
|
||||
|
||||
public FolderRepository(TenantDBContext context, IPermissionRepository Permissions)
|
||||
{
|
||||
db = context;
|
||||
this.Permissions = Permissions;
|
||||
}
|
||||
|
||||
public IEnumerable<Folder> GetFolders()
|
||||
{
|
||||
return db.Folder.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Folder> GetFolders(int SiteId)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions(SiteId, "Folder").ToList();
|
||||
IEnumerable<Folder> folders = db.Folder.Where(item => item.SiteId == SiteId);
|
||||
foreach(Folder folder in folders)
|
||||
{
|
||||
folder.Permissions = Permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
public Folder AddFolder(Folder Folder)
|
||||
{
|
||||
db.Folder.Add(Folder);
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Folder.SiteId, "Folder", Folder.FolderId, Folder.Permissions);
|
||||
return Folder;
|
||||
}
|
||||
|
||||
public Folder UpdateFolder(Folder Folder)
|
||||
{
|
||||
db.Entry(Folder).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
Permissions.UpdatePermissions(Folder.SiteId, "Folder", Folder.FolderId, Folder.Permissions);
|
||||
return Folder;
|
||||
}
|
||||
|
||||
public Folder GetFolder(int FolderId)
|
||||
{
|
||||
Folder folder = db.Folder.Find(FolderId);
|
||||
if (folder != null)
|
||||
{
|
||||
IEnumerable<Permission> permissions = Permissions.GetPermissions("Folder", folder.FolderId);
|
||||
folder.Permissions = Permissions.EncodePermissions(folder.FolderId, permissions);
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
public void DeleteFolder(int FolderId)
|
||||
{
|
||||
Folder Folder = db.Folder.Find(FolderId);
|
||||
Permissions.DeletePermissions(Folder.SiteId, "Folder", FolderId);
|
||||
db.Folder.Remove(Folder);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
15
Oqtane.Server/Repository/Interfaces/IFolderRepository.cs
Normal file
15
Oqtane.Server/Repository/Interfaces/IFolderRepository.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface IFolderRepository
|
||||
{
|
||||
IEnumerable<Folder> GetFolders();
|
||||
IEnumerable<Folder> GetFolders(int SiteId);
|
||||
Folder AddFolder(Folder Folder);
|
||||
Folder UpdateFolder(Folder Folder);
|
||||
Folder GetFolder(int FolderId);
|
||||
void DeleteFolder(int FolderId);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface INotificationRepository
|
||||
{
|
||||
IEnumerable<Notification> GetNotifications(int SiteId, int FromUserId, int ToUserId);
|
||||
Notification AddNotification(Notification Notification);
|
||||
Notification UpdateNotification(Notification Notification);
|
||||
Notification GetNotification(int NotificationId);
|
||||
void DeleteNotification(int NotificationId);
|
||||
}
|
||||
}
|
67
Oqtane.Server/Repository/NotificationRepository.cs
Normal file
67
Oqtane.Server/Repository/NotificationRepository.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class NotificationRepository : INotificationRepository
|
||||
{
|
||||
private TenantDBContext db;
|
||||
|
||||
public NotificationRepository(TenantDBContext context)
|
||||
{
|
||||
db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Notification> GetNotifications(int SiteId, int FromUserId, int ToUserId)
|
||||
{
|
||||
if (ToUserId == -1 && FromUserId == -1)
|
||||
{
|
||||
return db.Notification
|
||||
.Where(item => item.SiteId == SiteId)
|
||||
.Where(item => item.IsDelivered == false)
|
||||
.Include(item => item.FromUser)
|
||||
.Include(item => item.ToUser)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return db.Notification
|
||||
.Where(item => item.SiteId == SiteId)
|
||||
.Where(item => item.ToUserId == ToUserId || ToUserId == -1)
|
||||
.Where(item => item.FromUserId == FromUserId || FromUserId == -1)
|
||||
.Include(item => item.FromUser)
|
||||
.Include(item => item.ToUser)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public Notification AddNotification(Notification Notification)
|
||||
{
|
||||
db.Notification.Add(Notification);
|
||||
db.SaveChanges();
|
||||
return Notification;
|
||||
}
|
||||
|
||||
public Notification UpdateNotification(Notification Notification)
|
||||
{
|
||||
db.Entry(Notification).State = EntityState.Modified;
|
||||
db.SaveChanges();
|
||||
return Notification;
|
||||
}
|
||||
|
||||
public Notification GetNotification(int NotificationId)
|
||||
{
|
||||
return db.Notification.Find(NotificationId);
|
||||
}
|
||||
|
||||
public void DeleteNotification(int NotificationId)
|
||||
{
|
||||
Notification Notification = db.Notification.Find(NotificationId);
|
||||
db.Notification.Remove(Notification);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -104,6 +104,9 @@ namespace Oqtane.Repository
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Register", Parent = "", Path = "register", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Register, Oqtane.Client", Title = "User Registration", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Reset", Parent = "", Path = "reset", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.Reset, Oqtane.Client", Title = "Password Reset", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
SiteTemplate.Add(new PageTemplate { Name = "Profile", Parent = "", Path = "profile", Icon = "person", IsNavigation = false, IsPersonalizable = false, EditMode = false, PagePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", PageTemplateModules = new List<PageTemplateModule> {
|
||||
new PageTemplateModule { ModuleDefinitionName = "Oqtane.Modules.Admin.UserProfile, Oqtane.Client", Title = "User Profile", Pane = "Content", ModulePermissions = "[{\"PermissionName\":\"View\",\"Permissions\":\"All Users;Administrators\"},{\"PermissionName\":\"Edit\",\"Permissions\":\"Administrators\"}]", Content = "" }
|
||||
}});
|
||||
|
@ -23,7 +23,7 @@ namespace Oqtane.Repository
|
||||
return db.UserRole
|
||||
.Include(item => item.Role) // eager load roles
|
||||
.Include(item => item.User) // eager load users
|
||||
.Where(item => item.Role.SiteId == SiteId);
|
||||
.Where(item => item.Role.SiteId == SiteId || item.Role.SiteId == null);
|
||||
}
|
||||
|
||||
public IEnumerable<UserRole> GetUserRoles(int UserId, int SiteId)
|
||||
|
Reference in New Issue
Block a user