コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }