public ModifyRestrictionResponse ModifyRestriction(ModifyRestrictionRequest request) { ModifyRestrictionResponse response = new ModifyRestrictionResponse(); Restriction restriction = _restrictionRepository .FindBy(request.RestrictionId); restriction.Id = request.RestrictionId; restriction.RestrictionName = request.RestrictionName; restriction.RequirePermission = request.RequirePermission; restriction.RestrictionDescription = request.RestrictionDescription; if (restriction.GetBrokenRules().Count() > 0) { response.Errors = restriction.GetBrokenRules().ToList(); } else { try { _restrictionRepository.Save(restriction); _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); }
public JsonResult Update(RestrictionDetailView vm) { GetRestrictionRequest request = new GetRestrictionRequest(); request.RestrictionId = vm.RestrictionId; ModifyRestrictionRequest updateRequest = _restrictionService.GetRestriction(request).Restriction.ConvertToModifyRestrictionRequest(); updateRequest.RestrictionId = vm.RestrictionId; updateRequest.RestrictionName = vm.RestrictionName; updateRequest.RequirePermission = vm.RequirePermission; updateRequest.RestrictionDescription = vm.RestrictionDescription; ModifyRestrictionResponse response = _restrictionService.ModifyRestriction(updateRequest); return(Json(response)); }