public IActionResult ManualAddress(AddOrganisationManualViewModel viewModel) { ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); if (viewModel.Validate == true) { viewModel.ParseAndValidateParameters(Request, m => m.PoBox); viewModel.ParseAndValidateParameters(Request, m => m.Address1); viewModel.ParseAndValidateParameters(Request, m => m.Address2); viewModel.ParseAndValidateParameters(Request, m => m.Address3); viewModel.ParseAndValidateParameters(Request, m => m.TownCity); viewModel.ParseAndValidateParameters(Request, m => m.County); viewModel.ParseAndValidateParameters(Request, m => m.Country); viewModel.ParseAndValidateParameters(Request, m => m.PostCode); viewModel.ParseAndValidateParameters(Request, m => m.IsUkAddress); if (viewModel.HasAnyErrors()) { return(View("ManualAddress", viewModel)); } return(ProceedToNextPage(viewModel)); } return(View("ManualAddress", viewModel)); }
public IActionResult ManualConfirmPost(AddOrganisationManualViewModel viewModel) { ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); ValidateManuallyEnteredOrganisationDetails(viewModel); if (viewModel.HasAnyErrors()) { return(RedirectToAction("ManualConfirmGet", "AddOrganisationManualConfirm", viewModel)); } User user = ControllerHelper.GetGpgUserFromAspNetUser(User, dataRepository); Organisation organisation = organisationService.CreateOrganisationFromManualDataEntry( viewModel.GetSectorType(), viewModel.OrganisationName, viewModel.PoBox, viewModel.Address1, viewModel.Address2, viewModel.Address3, viewModel.TownCity, viewModel.County, viewModel.Country, viewModel.PostCode, viewModel.GetIsUkAddressAsBoolean(), null, // TODO ASK USER FOR COMPANY NUMBER viewModel.SicCodes, user); UserOrganisation userOrganisation = registrationRepository.CreateRegistration(organisation, user, Url); return(RedirectToConfirmationPage(userOrganisation)); }
public IActionResult ManualConfirmGet(AddOrganisationManualViewModel viewModel) { ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); ValidateManuallyEnteredOrganisationDetails(viewModel); PopulateViewModel(viewModel); return(View("ManualConfirm", viewModel)); }
private void PopulateViewModel(AddOrganisationManualViewModel viewModel) { if (viewModel.SicCodes == null) { viewModel.SicCodes = new List <int>(); } viewModel.SelectedSicCodes = dataRepository.GetAll <SicCode>() .Where(sc => viewModel.SicCodes.Contains(sc.SicCodeId)) .ToList(); }
private IActionResult ProceedToNextPage(AddOrganisationManualViewModel viewModel) { viewModel.Validate = null; // Required to prevent the next page immediately trying to validate the (empty) address if (viewModel.Editing == true) { // In the "Editing" flow, we go to each page, then back to the "Review" page viewModel.Editing = null; // To make the url look a bit nicer (the Review page implies we're editing so there's no need for "Editing" in the url) return(RedirectToAction("ManualConfirmGet", "AddOrganisationManualConfirm", viewModel)); } else { // In the normal "non-Editing" flow, we go to each page in turn - the next page here is the Address page return(RedirectToAction("ManualAddress", "AddOrganisationManualAddress", viewModel)); } }
private IActionResult ProceedToNextPage(AddOrganisationManualViewModel viewModel) { viewModel.Validate = null; // Required to prevent the next page immediately trying to validate the (empty) address viewModel.Editing = null; // To make the url look a bit nicer (the Review page implies we're editing so there's no need for "Editing" in the url) if (viewModel.Sector.Value == AddOrganisationSector.Private && (viewModel.SicCodes == null || viewModel.SicCodes.Count == 0)) { // If the user has selected "Private" and if they haven't selected any SIC codes, then we should prompt them to do this return(RedirectToAction("ManualSicCodes", "AddOrganisationManualSicCodes", viewModel)); } else { return(RedirectToAction("ManualConfirmGet", "AddOrganisationManualConfirm", viewModel)); } }
public IActionResult ManualSicCodes(AddOrganisationManualViewModel viewModel) { ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); if (viewModel.Validate == true) { return(ProceedToNextPage(viewModel)); } viewModel.SicSections = GetSicSectionsExceptPublicSector(); if (viewModel.SicCodes == null) { viewModel.SicCodes = new List <int>(); } return(View("ManualSicCodes", viewModel)); }
public IActionResult ManualChooseSector(AddOrganisationManualViewModel viewModel) { ControllerHelper.ThrowIfUserAccountRetiredOrEmailNotVerified(User, dataRepository); if (viewModel.Validate == true) { viewModel.ParseAndValidateParameters(Request, m => m.Sector); if (viewModel.HasAnyErrors()) { return(View("ManualChooseSector", viewModel)); } return(ProceedToNextPage(viewModel)); } return(View("ManualChooseSector", viewModel)); }
private static void ValidateManuallyEnteredOrganisationDetails(AddOrganisationManualViewModel viewModel) { if (string.IsNullOrWhiteSpace(viewModel.OrganisationName)) { viewModel.AddErrorFor(m => m.OrganisationName, "Enter the name of the organisation"); } if (string.IsNullOrWhiteSpace(viewModel.Address1)) { viewModel.AddErrorFor(m => m.Address1, "Enter the registered address of the organisation"); } if (!viewModel.IsUkAddress.HasValue) { viewModel.AddErrorFor(m => m.IsUkAddress, "Select if this organisation's address is a UK address"); } if (!viewModel.Sector.HasValue) { viewModel.AddErrorFor(m => m.Sector, "Choose which type of organisation you would like to add"); } }
public IActionResult ManualSicCodes(AddOrganisationManualViewModel viewModel) { return(RedirectToActionPermanent("ManualSicCodes", "AddOrganisationManualSicCodes")); }
public IActionResult ManualConfirmPost(AddOrganisationManualViewModel viewModel) { return(RedirectToActionPermanent("ManualConfirmPost", "AddOrganisationManualConfirm")); }
public IActionResult ManualChooseSector(AddOrganisationManualViewModel viewModel) { return(RedirectToActionPermanent("ManualChooseSector", "AddOrganisationManualChooseSector")); }
private IActionResult ProceedToNextPage(AddOrganisationManualViewModel viewModel) { viewModel.Validate = null; // Required to prevent the next page immediately trying to validate the (empty) address viewModel.Editing = null; // To make the url look a bit nicer (the Review page implies we're editing so there's no need for "Editing" in the url) return(RedirectToAction("ManualConfirmGet", "AddOrganisationManualConfirm", viewModel)); }