public void ChangePermissionByRole(RoleActionMappingChangeByRoleCommand command, out IList <RoleActionMapping> roleActionMappingsAdd, out IList <string> actionIdsRemove)
 {
     roleActionMappingsAdd = new List <RoleActionMapping>();
     actionIdsRemove       = new List <string>();
     if (command.ActionIdsRemove?.Length > 0)
     {
         foreach (var s in command.ActionIdsRemove)
         {
             RoleActionMapping roleActionMapping = Remove(command.RoleId, s);
             if (roleActionMapping != null)
             {
                 actionIdsRemove.Add(s);
             }
         }
     }
     if (command.ActionIdsAdd?.Length > 0)
     {
         foreach (var s in command.ActionIdsAdd)
         {
             RoleActionMapping roleActionMapping = Add(command.RoleId, s, string.Empty);
             if (roleActionMapping != null)
             {
                 roleActionMappingsAdd.Add(roleActionMapping);
             }
         }
     }
 }
        public RoleActionMapping Add(string roleId, string actionId, string attributes)
        {
            if (RoleActionMappings.Any(p => p.RoleId == roleId && p.ActionId == actionId))
            {
                return(null);
            }
            RoleActionMapping roleActionMapping = new RoleActionMapping(roleId, actionId, attributes);

            RoleActionMappings.Add(roleActionMapping);
            return(roleActionMapping);
        }
        public RoleActionMapping Remove(string roleId, string actionId)
        {
            RoleActionMapping roleActionMapping =
                RoleActionMappings.FirstOrDefault(p => p.RoleId == roleId && p.ActionId == actionId);

            if (roleActionMapping == null)
            {
                return(null);
            }
            RoleActionMappings.Remove(roleActionMapping);
            return(roleActionMapping);
        }