public Role Create(long structure, string containerPrototype, string workspaceType, string roleType, IEnumerable<string> rules = null, RoleBarrier roleBarrier = RoleBarrier.None) { var role = new Role() { RoleTypeName = roleType, StructureId = structure, ContainerTypeName = containerPrototype, WorkSpaceTypeName = workspaceType, RoleBarrier = roleBarrier }; if (rules != null) foreach(var r in rules.Select(e => _dbManager.Rule.Get(structure, e))) role.Rules.Add(r); _dbManager.DbContext.Roles.Add(role); _dbManager.DbContext.SaveChanges(); return role; }
private bool PermissionToEnroll(Container container, RoleType roleType, RoleBarrier roleBarrier) { var barrier = (int) roleBarrier; return _db.DbContext.Roles.Where(r => r.ContainerTypeName == container.Type.Name && r.RoleTypeName == roleType.Name && r.Barrier != barrier ).Any(); }