private void ValidateAgainstPersistence(ChangeLegalAddressViewModel model) { var personDto = WorkerServices.GetChangeLegalAddressViewModelPersonDto(model.PersonId); var persistenceValidationModelState = model.Validate(personDto); ModelState.Merge(persistenceValidationModelState); }
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); }
public ActionResult ChangeLegalAddress(ChangeLegalAddressViewModel model) { if (!this.ModelState.IsValid) { return(View(model)); } WorkerServices.ChangeLegalAddress(model); return(Redirect("/Registry/")); }
public ActionResult ChangeLegalAddress(ChangeLegalAddressViewModel model) { ValidateAgainstPersistence(model); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } WorkerServices.ChangeLegalAddress(model); return(Ok());; }
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 { })); }
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); }
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); }
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); }
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); }
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); }