public void it_should_create_a_new_address_entity_if_one_is_not_present_and_update_the_address_from_the_address_view_model() { const int expectedId = 1; const string expectedLine1 = "Line 1"; const int expectedCounty = 1; const int expectedCountry = 1; const string expectedPostcode = "BA2 3DQ"; var licence = new Licence { Id = expectedId, Address = null }; var model = new AddressViewModel { AddressLine1 = expectedLine1, CountyId = expectedCounty, CountryId = expectedCountry, Postcode = expectedPostcode }; licenceRepository.GetById(expectedId).Returns(licence); repository.Create <Address>().Returns(new Address()); var pdh = new LicenceApplicationPostDataHandler(mapper, repository, licenceRepository, statusRepository, dateTimeProvider); pdh.UpdateAddress(expectedId, l => l, model); repository.Received(1).Create <Address>(); repository.Received(1).Upsert(Arg.Is <Licence>(l => l.Address.AddressLine1.Equals(expectedLine1) && l.Address.CountyId == expectedCounty && l.Address.CountryId == expectedCountry && l.Address.Postcode.Equals(expectedPostcode))); }
public IActionResult SaveAddress(AddressViewModel model) { Session.SetSubmittedPage(FormSection.AlternativeBusinessRepresentative, 6); if (!ModelState.IsValid) { return(View(GetViewPath(FormSection.AlternativeBusinessRepresentative, 6), model)); } LicenceApplicationPostDataHandler.UpdateAddress(Session.GetCurrentLicenceId(), x => x.AlternativeBusinessRepresentatives.Single(abr => abr.Id == Session.GetCurrentAbrId()), model); return(CheckParentValidityAndRedirect(FormSection.AlternativeBusinessRepresentative, 6)); }
public IActionResult SaveAddress(AddressViewModel model) { Session.SetSubmittedPage(FormSection.DirectorOrPartner, 8); if (!ModelState.IsValid) { return(View(GetViewPath(FormSection.DirectorOrPartner, 8), model)); } if (Session.GetCurrentDopIsPa()) { LicenceApplicationPostDataHandler.UpdateAddress(Session.GetCurrentLicenceId(), l => l.PrincipalAuthorities.Single(pa => pa.Id == Session.GetCurrentPaId()), model); } LicenceApplicationPostDataHandler.UpdateAddress(Session.GetCurrentLicenceId(), l => l.DirectorOrPartners.Single(dop => dop.Id == Session.GetCurrentDopId()), model); return(CheckParentValidityAndRedirect(FormSection.DirectorOrPartner, 8)); }
private IActionResult OrganisationDetailsPost <T>(T model, string actionName) { Session.SetSubmittedPage(FormSection.OrganisationDetails, actionName); model = RepopulateDropdowns(model); if (!ModelState.IsValid) { return(View(actionName, model)); } var licenceId = Session.GetCurrentLicenceId(); if (model is AddressViewModel) { LicenceApplicationPostDataHandler.UpdateAddress(Session.GetCurrentLicenceId(), x => x, model as AddressViewModel); } else { LicenceApplicationPostDataHandler.Update(licenceId, x => x, model); } return(CheckParentValidityAndRedirect(FormSection.OrganisationDetails, actionName)); }