public async Task <IActionResult> ChooseOrganisation(ChooseOrganisationViewModel viewModel) { if (!string.IsNullOrEmpty(viewModel.Selected)) { return(RedirectToAction("Index", "Hub", new { viewModel.AccountId, accountLegalEntityId = viewModel.Selected })); } viewModel.AddOrganisations(await _legalEntitiesService.Get(viewModel.AccountId)); viewModel.SetManageAccountsUrl(_configuration.ManageApprenticeshipSiteUrl); if (string.IsNullOrEmpty(viewModel.Selected)) { ModelState.AddModelError(viewModel.Organisations.Any() ? viewModel.Organisations.First().AccountLegalEntityId : "OrganisationNotSelected", viewModel.OrganisationNotSelectedMessage); } return(View(viewModel)); }
public async Task <IActionResult> GetChooseOrganisation(ChooseOrganisationViewModel viewModel) { var legalEntities = await _legalEntitiesService.Get(viewModel.AccountId); if (legalEntities.Count() == 1) { return(RedirectToAction("Index", "Hub", new { viewModel.AccountId, accountLegalEntityId = legalEntities.First().AccountLegalEntityId })); } if (legalEntities.Count() > 1) { viewModel.AddOrganisations(legalEntities); viewModel.SetManageAccountsUrl(_configuration.ManageApprenticeshipSiteUrl); return(View("ChooseOrganisation", viewModel)); } return(RedirectToAction("Forbidden", "Apply", new { viewModel.AccountId })); }