コード例 #1
0
        private void ValidateAgainstPersistence(ChangeLegalAddressViewModel model)
        {
            var personDto = WorkerServices.GetChangeLegalAddressViewModelPersonDto(model.PersonId);
            var persistenceValidationModelState = model.Validate(personDto);

            ModelState.Merge(persistenceValidationModelState);
        }
コード例 #2
0
        public ChangeLegalAddressViewModel GetChangeAddressViewModel(ChangeLegalAddressViewModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            var person          = Repository.GetById <Person>(model.PersonId);
            var rehydratedModel = new ChangeLegalAddressViewModel()
            {
                PersonId        = person.Id,
                PersonFirstName = person.FirstName,
                PersonLastName  = person.LastName,
                EffectiveDate   = model.EffectiveDate,
                Address         = new Models.PostalAddress
                {
                    Address    = model.Address.Address,
                    City       = model.Address.City,
                    PostalCode = model.Address.PostalCode,
                    Province   = model.Address.Province,
                    Country    = model.Address.Country
                }
            };

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

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

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

            return(model);
        }
コード例 #8
0
        public void ChangeLegalAddress(ChangeLegalAddressViewModel 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 ChangeCompanyLegalAddressCommand(model.CompanyId,
                                                           model.LegalAddress.Address,
                                                           model.LegalAddress.PostalCode,
                                                           model.LegalAddress.City,
                                                           model.LegalAddress.Province,
                                                           model.LegalAddress.Country,
                                                           effectiveDate);

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

            if (company.LegalAddress != null)
            {
                model.LegalAddress.Address    = company.LegalAddress.Address;
                model.LegalAddress.City       = company.LegalAddress.City;
                model.LegalAddress.Country    = company.LegalAddress.Country;
                model.LegalAddress.PostalCode = company.LegalAddress.PostalCode;
                model.LegalAddress.Province   = company.LegalAddress.Province;
            }
            return(model);
        }
コード例 #10
0
        public ChangeLegalAddressViewModel GetChangeAddressViewModel(Guid personId)
        {
            var person = Repository.GetById <Person>(personId);
            var model  = new ChangeLegalAddressViewModel()
            {
                PersonId        = person.Id,
                PersonFirstName = person.FirstName,
                PersonLastName  = person.LastName
            };

            if (person.LegalAddress != null)
            {
                model.Address = new Models.PostalAddress
                {
                    Address    = person.LegalAddress.Address,
                    City       = person.LegalAddress.City,
                    PostalCode = person.LegalAddress.PostalCode,
                    Province   = person.LegalAddress.Province,
                    Country    = person.LegalAddress.Country
                };
            }
            return(model);
        }