public void Organisation_names_should_be_ordered_alphabetically() { // Arrange var model = new ChooseOrganisationViewModel(); // Act model.AddOrganisations(_organisations); // Assert model.Organisations[0].Name.Should().Be(_organisations[1].Name); model.Organisations[1].Name.Should().Be(_organisations[0].Name); model.Organisations[2].Name.Should().Be(_organisations[3].Name); model.Organisations[3].Name.Should().Be(_organisations[2].Name); }
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 })); }