コード例 #1
0
        public ModifyPosAddressResponse ModifyPosAddress(ModifyPosAddressRequest request)
        {
            ModifyPosAddressResponse response = new ModifyPosAddressResponse();

            PosAddress posAddress = _posAddressRepository
                                    .FindBy(request.AddressId);

            posAddress.Id           = request.AddressId;
            posAddress.Address      = request.Address;
            posAddress.PosMerchants = request.PosMerchants.ConvertToPosMerchants();


            if (posAddress.GetBrokenRules().Count() > 0)
            {
                response.Errors = posAddress.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _posAddressRepository.Save(posAddress);
                    _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 CreatePosAddressResponse CreatePosAddress(CreatePosAddressRequest request)
        {
            CreatePosAddressResponse response = new CreatePosAddressResponse();
            PosAddress posAddress             = new PosAddress();

            posAddress.Address      = request.Address;
            posAddress.PosMerchants = request.PosMerchants.ConvertToPosMerchants();

            if (posAddress.GetBrokenRules().Count() > 0)
            {
                response.Errors = posAddress.GetBrokenRules().ToList();
            }
            else
            {
                try {
                    _posAddressRepository.Add(posAddress);
                    _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);
        }