예제 #1
0
        public JsonResult Update(PermissionDetailView vm)
        {
            GetPermissionRequest request = new GetPermissionRequest();

            request.PermissionId = vm.PermissionId;

            ModifyPermissionRequest updateRequest = _permissionService.GetPermission(request).Permission.ConvertToModifyPermissionRequest();

            updateRequest.PermissionId          = vm.PermissionId;
            updateRequest.PermissionName        = vm.PermissionName;
            updateRequest.PermissionDescription = vm.PermissionDescription;
            updateRequest.ControllerName        = vm.ControllerName;
            updateRequest.ActionName            = vm.ActionName;
            updateRequest.IsAnonymous           = vm.IsAnonymous;
            updateRequest.IsDefaultAllow        = vm.IsDefaultAllow;

            ModifyPermissionResponse response = _permissionService.ModifyPermission(updateRequest);

            return(Json(response));
        }
예제 #2
0
        public ModifyPermissionResponse ModifyPermission(ModifyPermissionRequest request)
        {
            ModifyPermissionResponse response = new ModifyPermissionResponse();

            Permission permission = _permissionRepository
                                    .FindBy(request.PermissionId);

            permission.Id                    = request.PermissionId;
            permission.PermissionName        = request.PermissionName;
            permission.PermissionDescription = request.PermissionDescription;
            permission.ControllerName        = request.ControllerName;
            permission.ActionName            = request.ActionName;
            permission.IsAnonymous           = request.IsAnonymous;
            permission.IsDefaultAllow        = request.IsDefaultAllow;
            permission.Roles                 = request.Roles.ConvertToRoles();
            permission.Users                 = request.Users.ConvertToUsers();


            if (permission.GetBrokenRules().Count() > 0)
            {
                response.Errors = permission.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _permissionRepository.Save(permission);
                    _uow.Commit();
                    response.Errors = new List <BusinessRule>();
                } catch (Exception ex)
                {
                    response.Errors = new List <BusinessRule>();
                    response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
                }
            }


            return(response);
        }