Пример #1
0
        public Permission SetPermission(IRole role, IAction action, bool isAllowed)
        {
            Permission permission = PermissionRepository.GetPermissionByRole(role, action);

            if (permission == null)
                permission = new Permission(role, action, isAllowed);
            else
                permission.IsAllowed = isAllowed;

            PermissionRepository.SavePermission(permission);
            return permission;
        }
Пример #2
0
        public Permission SetPermission(IUser user, IAction action, bool isAllowed)
        {
            Permission permission = PermissionRepository.GetPermissionByUser(user, action);

            if (permission == null)
                permission = new Permission(user, action, isAllowed);
            else
                permission.IsAllowed = isAllowed;

            PermissionRepository.SavePermission(permission);

            return permission;
        }
Пример #3
0
 private void DeletePermission(Permission permission)
 {
     if (permission != null)
         PermissionRepository.DeletePermission(permission);
 }
Пример #4
0
 public bool HasPermission(PermissionObject permissionObject, Permission permissions)
 {
     return(IdentityUser.HasPermission(permissionObject, permissions) || UserId == SystemUserId);
 }
Пример #5
0
        public void RemovePermission(IRole role, IAction action)
        {
            Permission permission = PermissionRepository.GetPermissionByRole(role, action);

            DeletePermission(permission);
        }
Пример #6
0
        public void RemovePermission(IUser user, IAction action)
        {
            Permission permission = PermissionRepository.GetPermissionByUser(user, action);

            DeletePermission(permission);
        }