Пример #1
0
 public ServiceResult <RoleEntity> Add(RoleEntity roleEntity, List <PermissionDescriptor> permissionDescriptors)
 {
     return(BeginTransaction(() =>
     {
         var result = Add(roleEntity);
         if (result.HasViolation)
         {
             return result;
         }
         var permissions = new List <Permission>();
         permissionDescriptors.Where(m => m.Checked ?? false).Each(m =>
         {
             permissions.Add(new Permission
             {
                 RoleId = roleEntity.ID,
                 PermissionKey = m.Key,
                 Module = m.Module,
                 Title = m.Title,
                 ActionType = ActionType.Create
             });
         });
         _permissionService.AddRange(permissions.ToArray());
         return result;
     }));
 }
Пример #2
0
        public IActionResult Create(RoleEntity entity, List <PermissionDescriptor> PermissionSet)
        {
            Service.Add(entity);
            var permissions = new List <Permission>();

            PermissionSet.Where(m => m.Checked ?? false).Each(m =>
            {
                permissions.Add(new Permission
                {
                    RoleId        = entity.ID,
                    PermissionKey = m.Key,
                    Module        = m.Module,
                    Title         = m.Title,
                    ActionType    = ActionType.Create
                });
            });
            _permissionService.AddRange(permissions.ToArray());
            return(RedirectToAction("Index"));
        }