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);
        }
Beispiel #2
0
        private void ValidateAgainstPersistence(ChangeShippingAddressViewModel model)
        {
            var companyDto = WorkerServices.GetChangeShippingAddressViewModelCompanyDto(model.CompanyId);
            var persistenceValidationModelState = model.Validate(companyDto);

            ModelState.Merge(persistenceValidationModelState);
        }
Beispiel #3
0
 public ActionResult ChangeShippingAddress(ChangeShippingAddressViewModel model)
 {
     if (!this.ModelState.IsValid)
     {
         return(View(model));
     }
     WorkerServices.ChangeShippingAddress(model);
     return(Redirect("/Registry/"));
 }
Beispiel #4
0
 public ActionResult ChangeShippingAddress(ChangeShippingAddressViewModel model)
 {
     ValidateAgainstPersistence(model);
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     WorkerServices.ChangeShippingAddress(model);
     return(Ok());
 }
Beispiel #5
0
 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 { }));
 }
        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);
        }
        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);
        }
        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);
        }
        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);
        }