public CreateRestrictionResponse CreateRestriction(CreateRestrictionRequest request) { CreateRestrictionResponse response = new CreateRestrictionResponse(); Restriction restriction = new Restriction(); 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.Add(restriction); _uow.Commit(); response.Errors = new List <BusinessRule>(); } catch (Exception ex) { List <BusinessRule> errors = new List <BusinessRule>(); do { errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message)); ex = ex.InnerException; } while (ex != null); response.Errors = errors; } } return(response); }
public JsonResult Create(RestrictionDetailView vm) { CreateRestrictionRequest request = new CreateRestrictionRequest(); request.RestrictionName = vm.RestrictionName; request.RequirePermission = vm.RequirePermission; request.RestrictionDescription = vm.RestrictionDescription; CreateRestrictionResponse response = _restrictionService.CreateRestriction(request); return(Json(response)); }