public async Task <ActionResult> EditGovernanceMode(EditGovernanceModeViewModel viewModel) { try { await _establishmentWriteService.UpdateGovernanceModeAsync(viewModel.Urn.Value, viewModel.GovernanceMode.Value, User); var url = Url.RouteUrl("EstabDetails", new { id = viewModel.Urn, saved = true }); return(Redirect($"{url}#school-governance")); } catch (EduSecurityException) // for some reason the API responds with a 403 for this one, even though it's nothing to do with authentication/authorization. { return(RedirectToRoute("EstabEditGovernanceMode", new { establishmentUrn = viewModel.Urn, failed = true })); } }
public async Task <ActionResult> EditGovernanceMode(int?establishmentUrn, bool failed = false) { establishmentUrn.AssertIsNotEmpty(nameof(establishmentUrn)); if (failed) { ModelState.AddModelError("", "Unable to update Governance"); } var viewModel = new EditGovernanceModeViewModel { Urn = establishmentUrn.Value, PermissibleGovernanceModes = (await _establishmentReadService.GetPermissibleLocalGovernorsAsync(establishmentUrn.Value, User)).Select(x => (eGovernanceMode)x.Id).ToArray() }; await _layoutHelper.PopulateLayoutProperties(viewModel, establishmentUrn, null, User, x => viewModel.GovernanceMode = x.GovernanceMode ?? eGovernanceMode.LocalGovernors); return(View(viewModel)); }