コード例 #1
0
        public JsonResult Create(PosMerchantDetailView vm)
        {
            CreatePosMerchantRequest request = new CreatePosMerchantRequest();

            request.MerchantName = vm.MerchantName;
            GetPosAddressRequest posAddressRequest = new GetPosAddressRequest();

            posAddressRequest.AddressId    = vm.PosAddressAddressId;
            request.PosAddress             = _posAddressService.GetPosAddress(posAddressRequest).PosAddress;
            request.BusinessName           = vm.BusinessName;
            request.BannerName             = vm.BannerName;
            request.MerchantIdByHeadQuater = vm.MerchantIdByHeadQuater;
            CreatePosMerchantResponse response = _posMerchantService.CreatePosMerchant(request);

            return(Json(response));
        }
コード例 #2
0
        public CreatePosMerchantResponse CreatePosMerchant(CreatePosMerchantRequest request)
        {
            CreatePosMerchantResponse response = new CreatePosMerchantResponse();
            PosMerchant posMerchant            = new PosMerchant();

            posMerchant.MerchantName           = request.MerchantName;
            posMerchant.BusinessName           = request.BusinessName;
            posMerchant.BannerName             = request.BannerName;
            posMerchant.MerchantIdByHeadQuater = request.MerchantIdByHeadQuater;
            posMerchant.PosReceiptOfTestings   = request.PosReceiptOfTestings.ConvertToPosReceiptOfTestings();
            posMerchant.PosAddress             = request.PosAddress.ConvertToPosAddress();

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