Fix issue saving permissions associated to global roles

This commit is contained in:
Shaun Walker 2019-08-30 10:45:44 -04:00
parent 88a08c8863
commit c651dedffd
4 changed files with 16 additions and 2 deletions

View File

@ -7,6 +7,7 @@ namespace Oqtane.Repository
{
IEnumerable<Role> GetRoles();
IEnumerable<Role> GetRoles(int SiteId);
IEnumerable<Role> GetRoles(int SiteId, bool IncludeGlobalRoles);
Role AddRole(Role Role);
Role UpdateRole(Role Role);
Role GetRole(int RoleId);

View File

@ -192,7 +192,7 @@ namespace Oqtane.Repository
public List<Permission> DecodePermissions(string PermissionStrings, int SiteId, string EntityName, int EntityId)
{
List<Permission> permissions = new List<Permission>();
List<Role> roles = Roles.GetRoles(SiteId).ToList();
List<Role> roles = Roles.GetRoles(SiteId, true).ToList();
string securityid = "";
foreach (PermissionString permissionstring in JsonSerializer.Deserialize<List<PermissionString>>(PermissionStrings))
{

View File

@ -38,6 +38,19 @@ namespace Oqtane.Repository
}
}
public IEnumerable<Role> GetRoles(int SiteId, bool IncludeGlobalRoles)
{
try
{
return db.Role.Where(item => item.SiteId == SiteId || item.SiteId == null).ToList();
}
catch
{
throw;
}
}
public Role AddRole(Role Role)
{
try

View File

@ -5,7 +5,7 @@ namespace Oqtane.Models
public class Role : IAuditable
{
public int RoleId { get; set; }
public int SiteId { get; set; }
public int? SiteId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsAutoAssigned { get; set; }