コード例 #1
0
        public ChangeShippingAddressViewModel GetChangeShippingAddressViewModel(ChangeShippingAddressViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var company = Repository.GetById <Company>(model.CompanyId);

            var viewModel = new ChangeShippingAddressViewModel()
            {
                CompanyId       = company.Id,
                CompanyName     = company.CompanyName,
                ShippingAddress = new Models.PostalAddress
                {
                    Address    = model.ShippingAddress.Address,
                    City       = model.ShippingAddress.City,
                    PostalCode = model.ShippingAddress.PostalCode,
                    Province   = model.ShippingAddress.Province,
                    Country    = model.ShippingAddress.Country
                }
            };

            return(viewModel);
        }
コード例 #2
0
        private void ValidateAgainstPersistence(ChangeShippingAddressViewModel model)
        {
            var companyDto = WorkerServices.GetChangeShippingAddressViewModelCompanyDto(model.CompanyId);
            var persistenceValidationModelState = model.Validate(companyDto);

            ModelState.Merge(persistenceValidationModelState);
        }
コード例 #3
0
ファイル: CompanyController.cs プロジェクト: pixelia-es/Merp
 public ActionResult ChangeShippingAddress(ChangeShippingAddressViewModel model)
 {
     if (!this.ModelState.IsValid)
     {
         return(View(model));
     }
     WorkerServices.ChangeShippingAddress(model);
     return(Redirect("/Registry/"));
 }
コード例 #4
0
 public ActionResult ChangeShippingAddress(ChangeShippingAddressViewModel model)
 {
     ValidateAgainstPersistence(model);
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     WorkerServices.ChangeShippingAddress(model);
     return(Ok());
 }
コード例 #5
0
ファイル: CompanyController.cs プロジェクト: yersans/Merp
 public ActionResult ChangeShippingAddress(ChangeShippingAddressViewModel model)
 {
     ValidateAgainstPersistence(model);
     if (!ModelState.IsValid)
     {
         var rehydratedModel = WorkerServices.GetChangeShippingAddressViewModel(model);
         return(View(rehydratedModel));
     }
     WorkerServices.ChangeShippingAddress(model);
     return(RedirectToRoute("registry", new { }));
 }
コード例 #6
0
        public void ChangeShippingAddress(ChangeShippingAddressViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var cmd = new ChangeCompanyShippingAddressCommand(model.CompanyId,
                                                              model.ShippingAddress.Address,
                                                              model.ShippingAddress.PostalCode,
                                                              model.ShippingAddress.City,
                                                              model.ShippingAddress.Province,
                                                              model.ShippingAddress.Country);

            Bus.Send(cmd);
        }
コード例 #7
0
        public ChangeShippingAddressViewModel GetChangeShippingAddressViewModel(Guid companyId)
        {
            var company = Repository.GetById <Company>(companyId);
            var model   = new ChangeShippingAddressViewModel()
            {
                CompanyId       = company.Id,
                CompanyName     = company.CompanyName,
                ShippingAddress = new Models.PostalAddress
                {
                    Address    = company.ShippingAddress.Address,
                    City       = company.ShippingAddress.City,
                    PostalCode = company.ShippingAddress.PostalCode,
                    Province   = company.ShippingAddress.Province,
                    Country    = company.ShippingAddress.Country
                }
            };

            return(model);
        }
コード例 #8
0
        public void ChangeShippingAddress(ChangeShippingAddressViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var effectiveDateTime = model.EffectiveDate;
            var effectiveDate     = new DateTime(effectiveDateTime.Year, effectiveDateTime.Month, effectiveDateTime.Day);

            var cmd = new ChangeCompanyShippingAddressCommand(model.CompanyId,
                                                              model.ShippingAddress.Address,
                                                              model.ShippingAddress.PostalCode,
                                                              model.ShippingAddress.City,
                                                              model.ShippingAddress.Province,
                                                              model.ShippingAddress.Country,
                                                              effectiveDate);

            Bus.Send(cmd);
        }
コード例 #9
0
        public ChangeShippingAddressViewModel GetChangeShippingAddressViewModel(Guid companyId)
        {
            var company = Repository.GetById <Company>(companyId);
            var model   = new ChangeShippingAddressViewModel()
            {
                CompanyId       = company.Id,
                CompanyName     = company.CompanyName,
                ShippingAddress = new Models.PostalAddress()
            };

            if (company.ShippingAddress != null)
            {
                model.ShippingAddress.Address    = company.ShippingAddress.Address;
                model.ShippingAddress.City       = company.ShippingAddress.City;
                model.ShippingAddress.Country    = company.ShippingAddress.Country;
                model.ShippingAddress.PostalCode = company.ShippingAddress.PostalCode;
                model.ShippingAddress.Province   = company.ShippingAddress.Province;
            }
            return(model);
        }