Beispiel #1
0
        public object Visit(RoleEquivalence e)
        {
            if (e.modality != Statement.Modality.IS)
            {
                return(CreateNull());
            }

            // forall X,Y in e.Equivalence return X[=Y & Y[=X
            return(INTERSECT_SYMETRIC_FUN(e.Equivalents, ROLINC));
        }
        public async Task <ActionResult> ReplaceChair(int establishmentUrn, int gid)
        {
            var governor = await _governorsReadService.GetGovernorAsync(gid, User);

            var roles = new List <eLookupGovernorRole>
            {
                (eLookupGovernorRole)governor.RoleId
            };

            if (EnumSets.SharedGovernorRoles.Contains(governor.RoleId.Value))
            {
                var localEquivalent =
                    RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId);
                if (localEquivalent != null)
                {
                    roles.Add(localEquivalent.Value);
                }
            }
            else
            {
                roles.AddRange(RoleEquivalence.GetEquivalentToLocalRole((eLookupGovernorRole)governor.RoleId));
            }

            var governors = (await _governorsReadService.GetSharedGovernorsAsync(establishmentUrn, User)).Where(g => roles.Contains((eLookupGovernorRole)g.RoleId) && g.Id != gid).ToList();

            var model = new ReplaceChairViewModel
            {
                ExistingGovernorId = gid,
                GovernorFullName   = governor.GetFullName(),
                DateTermEnds       = new DateTimeViewModel(governor.AppointmentEndDate),
                NewLocalGovernor   = new GovernorViewModel
                {
                    DisplayPolicy = await _governorsReadService.GetEditorDisplayPolicyAsync((RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId.Value) ?? (eLookupGovernorRole)governor.RoleId.Value), false, User)
                },
                SharedGovernors = (await Task.WhenAll(governors.Select(async g => await SharedGovernorViewModel.MapFromGovernor(g, establishmentUrn, _cachedLookupService)))).ToList(),
                NewChairType    = ReplaceChairViewModel.ChairType.LocalChair,
                Role            = (eLookupGovernorRole)governor.RoleId,
                RoleName        = _nomenclatureService.GetGovernorRoleName((eLookupGovernorRole)governor.RoleId, eTextCase.Lowerase, false)
            };

            await PopulateSelectLists(model.NewLocalGovernor);

            await _layoutHelper.PopulateLayoutProperties(model, establishmentUrn, null, User);

            return(View(model));
        }
        public async Task <ActionResult> SelectSharedGovernor(SelectSharedGovernorViewModel model)
        {
            if (ModelState.IsValid)
            {
                foreach (var governor in model.Governors.Where(g => (g.Selected && !g.PreExisting) || string.Equals(g.Id.ToString(), model.SelectedGovernorId)))
                {
                    var response = await _governorsWriteService.AddSharedGovernorAppointmentAsync(governor.Id, model.Urn.Value, governor.AppointmentStartDate.ToDateTime().Value, governor.AppointmentEndDate.ToDateTime(), User);

                    if (!response.Success)
                    {
                        response.ApplyToModelState(ControllerContext);
                    }
                }

                if (ModelState.IsValid)
                {
                    var url = $"{Url.RouteUrl("EstabDetails", new { id = model.Urn, saved = true })}#school-governance";

                    return(Redirect(url));
                }
            }

            var governors = (await Task.WhenAll(
                                 (await _governorsReadService.GetSharedGovernorsAsync(model.Urn.Value, User))
                                 .Where(g => RoleEquivalence.GetEquivalentRole(model.Role).Contains((eLookupGovernorRole)g.RoleId))
                                 .Select(g => SharedGovernorViewModel.MapFromGovernor(g, model.Urn.Value, _cachedLookupService)))).ToList();

            foreach (var previousGovernor in model.Governors)
            {
                var newGovernor = governors.Single(g => g.Id == previousGovernor.Id);
                if (!newGovernor.PreExisting)
                {
                    newGovernor.Selected = previousGovernor.Selected;
                }
            }

            model.Governors = governors;
            await _layoutHelper.PopulateLayoutProperties(model, model.Urn.Value, null, User);

            return(View(model));
        }
        private void CreateGrids(GovernorsDetailsDto dto, IEnumerable <GovernorModel> governors, bool isHistoric, int?groupUid, int?establishmentUrn)
        {
            var roles = dto.ApplicableRoles.Where(role => !EnumSets.eSharedGovernorRoles.Contains(role)
                                                  ||
                                                  (RoleEquivalence.GetLocalEquivalentToSharedRole(role) != null &&
                                                   !dto.ApplicableRoles.Contains(RoleEquivalence.GetLocalEquivalentToSharedRole(role).Value)));

            foreach (var role in roles)
            {
                var equivalantRoles = RoleEquivalence.GetEquivalentToLocalRole(role).Cast <int>().ToList();
                var pluralise       = !EnumSets.eSingularGovernorRoles.Contains(role);


                var grid = new GovernorGridViewModel($"{_nomenclatureService.GetGovernorRoleName(role, eTextCase.SentenceCase, pluralise)}{(isHistoric ? " (in past 12 months)" : string.Empty)}")
                {
                    Tag              = isHistoric ? "historic" : "current",
                    Role             = role,
                    IsSharedRole     = EnumSets.eSharedGovernorRoles.Contains(role),
                    GroupUid         = groupUid,
                    EstablishmentUrn = establishmentUrn,
                    IsHistoricRole   = isHistoric,
                    RoleName         = _nomenclatureService.GetGovernorRoleName(role)
                };

                var displayPolicy = dto.RoleDisplayPolicies.Get(role);
                Guard.IsNotNull(displayPolicy, () => new Exception($"The display policy should not be null for the role '{role}'"));
                bool includeEndDate = ((isHistoric && role == GR.Member || role != GR.Member) && displayPolicy.AppointmentEndDate) ||
                                      (role.OneOfThese(GR.ChiefFinancialOfficer, GR.AccountingOfficer) && isHistoric);

                SetupHeader(role, grid, displayPolicy, includeEndDate);

                var list = governors.Where(x => x.RoleId.HasValue && equivalantRoles.Contains(x.RoleId.Value));
                foreach (var governor in list)
                {
                    var isShared       = governor.RoleId.HasValue && EnumSets.SharedGovernorRoles.Contains(governor.RoleId.Value);
                    var establishments = string.Join(", ",
                                                     governor.Appointments?.Select(a => $"{a.EstablishmentName}, URN: {a.EstablishmentUrn}") ??
                                                     new string[] { });
                    var appointment = governor.Appointments?.SingleOrDefault(a => a.EstablishmentUrn == EstablishmentUrn);
                    var startDate   = (isShared && appointment != null) ? appointment.AppointmentStartDate : governor.AppointmentStartDate;
                    var endDate     = (isShared && appointment != null) ? appointment.AppointmentEndDate : governor.AppointmentEndDate;

                    var row = grid.AddRow(governor, endDate)
                              .AddCell(governor.GetFullName(), displayPolicy.FullName)
                              .AddCell(string.IsNullOrWhiteSpace(establishments) ? null : establishments, role.OneOfThese(GR.LocalGovernor, GR.ChairOfLocalGoverningBody))
                              .AddCell(governor.Id, displayPolicy.Id)
                              .AddCell(AppointingBodies.FirstOrDefault(x => x.Id == governor.AppointingBodyId)?.Name, displayPolicy.AppointingBodyId)
                              .AddCell(startDate?.ToString("dd/MM/yyyy"), displayPolicy.AppointmentStartDate)
                              .AddCell(endDate?.ToString("dd/MM/yyyy"), includeEndDate)
                              .AddCell(governor.PostCode, displayPolicy.PostCode)
                              .AddCell(governor.DOB?.ToString("dd/MM/yyyy"), displayPolicy.DOB)
                              .AddCell(governor.GetPreviousFullName(), displayPolicy.PreviousFullName)
                              .AddCell(governor.EmailAddress, displayPolicy.EmailAddress)
                              .AddCell(governor.TelephoneNumber, displayPolicy.TelephoneNumber);

                    if (isHistoric)
                    {
                        var gov = new HistoricGovernorViewModel
                        {
                            AppointingBodyId     = governor.AppointingBodyId,
                            AppointingBody       = AppointingBodies.FirstOrDefault(x => x.Id == governor.AppointingBodyId)?.Name,
                            AppointmentEndDate   = new DateTimeViewModel(governor.AppointmentEndDate),
                            AppointmentStartDate = new DateTimeViewModel(governor.AppointmentStartDate),
                            FullName             = governor.GetFullName(),
                            RoleName             = _nomenclatureService.GetGovernorRoleName(role)
                        };

                        HistoricGovernors.Add(gov);
                    }
                }

                grid.Rows         = grid.Rows.OrderByDescending(x => x.SortValue).ThenBy(x => x.Model.GetFullName()).ToList();
                HistoricGovernors = HistoricGovernors.OrderByDescending(x => x.AppointmentEndDate.ToDateTime()).ThenBy(x => x.FullName).ToList();

                if (isHistoric)
                {
                    HistoricGrids.Add(grid);
                }
                else
                {
                    Grids.Add(grid);
                }
            }
        }
Beispiel #5
0
        public async Task <ActionResult> ReplaceChair(ReplaceChairViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.NewChairType == ReplaceChairViewModel.ChairType.SharedChair)
                {
                    var newGovernor = model.SharedGovernors.SingleOrDefault(s => s.Id == model.SelectedGovernorId);

                    var validation = await _governorsWriteService.AddSharedGovernorAppointmentAsync(model.SelectedGovernorId,
                                                                                                    model.Urn.Value,
                                                                                                    model.DateTermEnds.ToDateTime().Value.AddDays(1),
                                                                                                    newGovernor.AppointmentEndDate.ToDateTime(), User);

                    if (!validation.HasErrors)
                    {
                        var url =
                            $"{Url.RouteUrl("EstabDetails", new {id = model.Urn, saved = true})}#school-governance";
                        return(Redirect(url));
                    }

                    validation.ApplyToModelState(ControllerContext);
                }
                else
                {
                    var newGovernor = new GovernorModel
                    {
                        AppointingBodyId     = model.NewLocalGovernor.AppointingBodyId,
                        AppointmentEndDate   = model.NewLocalGovernor.AppointmentEndDate.ToDateTime(),
                        AppointmentStartDate = model.DateTermEnds.ToDateTime().Value.AddDays(1),
                        DOB                       = model.NewLocalGovernor.DOB.ToDateTime(),
                        EmailAddress              = model.NewLocalGovernor.EmailAddress,
                        EstablishmentUrn          = model.Urn,
                        Person_FirstName          = model.NewLocalGovernor.FirstName,
                        Person_MiddleName         = model.NewLocalGovernor.MiddleName,
                        Person_LastName           = model.NewLocalGovernor.LastName,
                        Person_TitleId            = model.NewLocalGovernor.GovernorTitleId,
                        PreviousPerson_FirstName  = model.NewLocalGovernor.PreviousFirstName,
                        PreviousPerson_MiddleName = model.NewLocalGovernor.PreviousMiddleName,
                        PreviousPerson_LastName   = model.NewLocalGovernor.PreviousLastName,
                        PreviousPerson_TitleId    = model.NewLocalGovernor.PreviousTitleId,
                        PostCode                  = model.NewLocalGovernor.PostCode,
                        RoleId                    = (int)(RoleEquivalence.GetLocalEquivalentToSharedRole(model.Role) ?? model.Role),
                        TelephoneNumber           = model.NewLocalGovernor.TelephoneNumber
                    };

                    var validation = await _governorsWriteService.ValidateAsync(newGovernor, User);

                    if (!validation.HasErrors)
                    {
                        GovernorModel oldGovernorModel = null;
                        if (model.Reinstate)
                        {
                            oldGovernorModel =
                                await _governorsReadService.GetGovernorAsync(model.ExistingGovernorId, User);
                        }

                        await _governorsWriteService.SaveAsync(newGovernor, User);

                        if (model.SelectedPreviousExistingNonChairId.HasValue)
                        {
                            await RetireGovernorAsync(model.SelectedPreviousExistingNonChairId.Value,
                                                      model.DateTermEnds.ToDateTime().GetValueOrDefault());
                        }

                        if (model.Reinstate) // re-instate the old chair to be the non-chair equivalent role.
                        {
                            await ReInstateChairAsNonChairAsync(model.ExistingGovernorId,
                                                                newGovernor.AppointmentStartDate.GetValueOrDefault(),
                                                                (oldGovernorModel?.AppointmentEndDate).GetValueOrDefault(),
                                                                eLookupGovernorRole.ChairOfLocalGoverningBody);
                        }

                        var url =
                            $"{Url.RouteUrl("EstabDetails", new {id = model.Urn, saved = true})}#school-governance";
                        return(Redirect(url));
                    }

                    validation.ApplyToModelState(ControllerContext, nameof(model.NewLocalGovernor), true);
                }
            }

            var governor = await _governorsReadService.GetGovernorAsync(model.ExistingGovernorId, User);

            var roles = new List <eLookupGovernorRole> {
                (eLookupGovernorRole)governor.RoleId
            };

            if (EnumSets.SharedGovernorRoles.Contains(governor.RoleId.Value))
            {
                var localEquivalent =
                    RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId);
                if (localEquivalent != null)
                {
                    roles.Add(localEquivalent.Value);
                }
            }
            else
            {
                roles.AddRange(RoleEquivalence.GetEquivalentToLocalRole((eLookupGovernorRole)governor.RoleId));
            }

            var governors = (await _governorsReadService.GetSharedGovernorsAsync(model.Urn.Value, User)).Where(g =>
                                                                                                               roles.Contains((eLookupGovernorRole)g.RoleId) && g.Id != model.ExistingGovernorId).ToList();

            model.NewLocalGovernor.DisplayPolicy = await _governorsReadService.GetEditorDisplayPolicyAsync(
                (RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId.Value) ??
                 (eLookupGovernorRole)governor.RoleId.Value), false, User);

            var sourceGovernors = (await Task.WhenAll(governors.Select(async g => await SharedGovernorViewModel.MapFromGovernor(g, model.Urn.Value, _cachedLookupService)))).ToList();

            if (model.SharedGovernors == null)
            {
                model.SharedGovernors = sourceGovernors;
            }
            else
            {
                for (var i = 0; i < model.SharedGovernors?.Count; i++)
                {
                    // if this is the one the user selected, we dont want to change any of the values they entered
                    if (model.SharedGovernors[i].Selected)
                    {
                        model.SharedGovernors[i].SharedWith =
                            sourceGovernors.First(x => x.Id == model.SharedGovernors[i].Id).SharedWith;
                    }
                    else
                    {
                        model.SharedGovernors[i]          = sourceGovernors.First(x => x.Id == model.SharedGovernors[i].Id);
                        model.SharedGovernors[i].Selected = false;
                    }
                }
            }

            await PopulateSelectLists(model.NewLocalGovernor);

            await _layoutHelper.PopulateLayoutProperties(model, model.Urn, null, User);


            var models = await _governorsReadService.GetGovernorListAsync(model.Urn, principal : User);

            var localGovernors = models.CurrentGovernors.Where(x => x.RoleId == (int)eLookupGovernorRole.LocalGovernor).OrderBy(x => x.Person_LastName).ToArray();

            if (model.SelectedPreviousExistingNonChairId.HasValue)
            {
                model.SelectedNonChair = localGovernors.FirstOrDefault(x => x.Id == model.SelectedPreviousExistingNonChairId);
            }

            model.ExistingNonChairs = localGovernors.Select(x => new SelectListItem
            {
                Text     = x.Person_FirstName + " " + x.Person_LastName,
                Value    = x.Id.ToString(),
                Selected = model.SelectedPreviousExistingNonChairId.HasValue &&
                           model.SelectedPreviousExistingNonChairId.Value == x.Id
            });


            return(View(model));
        }
Beispiel #6
0
        public async Task <ActionResult> ReplaceChair(int establishmentUrn, int gid)
        {
            var replaceGovernorState = new
            {
                ReplacementGovernorId = Request.QueryString["rgid"].ToInteger(),
                DateTermEndsDay       = Request.QueryString["d"].ToInteger(),
                DateTermEndsMonth     = Request.QueryString["m"].ToInteger(),
                DateTermEndsYear      = Request.QueryString["y"].ToInteger(),
                Reinstate             = Request.QueryString["ri"] == "true"
            };

            var governor = await _governorsReadService.GetGovernorAsync(gid, User);

            var roles = new List <eLookupGovernorRole>
            {
                (eLookupGovernorRole)governor.RoleId
            };

            if (EnumSets.SharedGovernorRoles.Contains(governor.RoleId.Value))
            {
                var localEquivalent =
                    RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId);
                if (localEquivalent != null)
                {
                    roles.Add(localEquivalent.Value);
                }
            }
            else
            {
                roles.AddRange(RoleEquivalence.GetEquivalentToLocalRole((eLookupGovernorRole)governor.RoleId));
            }

            var governors = (await _governorsReadService.GetSharedGovernorsAsync(establishmentUrn, User)).Where(g => roles.Contains((eLookupGovernorRole)g.RoleId) && g.Id != gid).ToList();

            var model = new ReplaceChairViewModel
            {
                ExistingGovernorId = gid,
                GovernorFullName   = governor.GetFullName(),
                DateTermEnds       = new DateTimeViewModel(governor.AppointmentEndDate),
                NewLocalGovernor   = new GovernorViewModel
                {
                    DisplayPolicy = await _governorsReadService.GetEditorDisplayPolicyAsync((RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId.Value) ?? (eLookupGovernorRole)governor.RoleId.Value), false, User)
                },
                SharedGovernors = (await Task.WhenAll(governors.Select(async g => await SharedGovernorViewModel.MapFromGovernor(g, establishmentUrn, _cachedLookupService)))).ToList(),
                NewChairType    = ReplaceChairViewModel.ChairType.LocalChair,
                Role            = (eLookupGovernorRole)governor.RoleId,
                RoleName        = _nomenclatureService.GetGovernorRoleName((eLookupGovernorRole)governor.RoleId, eTextCase.Lowerase, false)
            };

            var models = await _governorsReadService.GetGovernorListAsync(establishmentUrn, principal : User);

            var localGovernors = models.CurrentGovernors.Where(x => x.RoleId == (int)eLookupGovernorRole.LocalGovernor).OrderBy(x => x.Person_LastName).ToArray();

            if (replaceGovernorState.ReplacementGovernorId.HasValue)
            {
                model.SelectedNonChair = localGovernors.FirstOrDefault(x => x.Id == replaceGovernorState.ReplacementGovernorId);
                PrepopulateFields(model.SelectedNonChair, model);
            }

            model.ExistingNonChairs = localGovernors.Select(x => new SelectListItem {
                Text = x.Person_FirstName + " " + x.Person_LastName, Value = x.Id.ToString(), Selected = replaceGovernorState.ReplacementGovernorId.HasValue && replaceGovernorState.ReplacementGovernorId.Value == x.Id
            });

            await PopulateSelectLists(model.NewLocalGovernor);

            await _layoutHelper.PopulateLayoutProperties(model, establishmentUrn, null, User);

            if (replaceGovernorState.DateTermEndsDay.HasValue)
            {
                model.Reinstate          = replaceGovernorState.Reinstate;
                model.DateTermEnds.Day   = replaceGovernorState.DateTermEndsDay;
                model.DateTermEnds.Month = replaceGovernorState.DateTermEndsMonth;
                model.DateTermEnds.Year  = replaceGovernorState.DateTermEndsYear;
            }

            return(View(model));
        }
        public async Task <ActionResult> ReplaceChair(ReplaceChairViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.NewChairType == ReplaceChairViewModel.ChairType.SharedChair)
                {
                    var newGovernor = model.SharedGovernors.SingleOrDefault(s => s.Id == model.SelectedGovernorId);

                    await _governorsWriteService.AddSharedGovernorAppointmentAsync(model.SelectedGovernorId, model.Urn.Value,
                                                                                   model.DateTermEnds.ToDateTime().Value.AddDays(1),
                                                                                   newGovernor.AppointmentEndDate.ToDateTime(), User);

                    var url = $"{Url.RouteUrl("EstabDetails", new { id = model.Urn, saved = true })}#school-governance";
                    return(Redirect(url));
                }
                else
                {
                    var newGovernor = new GovernorModel
                    {
                        AppointingBodyId     = model.NewLocalGovernor.AppointingBodyId,
                        AppointmentEndDate   = model.NewLocalGovernor.AppointmentEndDate.ToDateTime(),
                        AppointmentStartDate = model.DateTermEnds.ToDateTime().Value.AddDays(1),
                        DOB                       = model.NewLocalGovernor.DOB.ToDateTime(),
                        EmailAddress              = model.NewLocalGovernor.EmailAddress,
                        EstablishmentUrn          = model.Urn,
                        Person_FirstName          = model.NewLocalGovernor.FirstName,
                        Person_MiddleName         = model.NewLocalGovernor.MiddleName,
                        Person_LastName           = model.NewLocalGovernor.LastName,
                        Person_TitleId            = model.NewLocalGovernor.GovernorTitleId,
                        PreviousPerson_FirstName  = model.NewLocalGovernor.PreviousFirstName,
                        PreviousPerson_MiddleName = model.NewLocalGovernor.PreviousMiddleName,
                        PreviousPerson_LastName   = model.NewLocalGovernor.PreviousLastName,
                        PreviousPerson_TitleId    = model.NewLocalGovernor.PreviousTitleId,
                        PostCode                  = model.NewLocalGovernor.PostCode,
                        RoleId                    = (int)(RoleEquivalence.GetLocalEquivalentToSharedRole(model.Role) ?? model.Role),
                        TelephoneNumber           = model.NewLocalGovernor.TelephoneNumber
                    };

                    var validation = await _governorsWriteService.ValidateAsync(newGovernor, User);

                    if (!validation.HasErrors)
                    {
                        await _governorsWriteService.SaveAsync(newGovernor, User);

                        var url = $"{Url.RouteUrl("EstabDetails", new { id = model.Urn, saved = true })}#school-governance";
                        return(Redirect(url));
                    }

                    validation.ApplyToModelState(ControllerContext, nameof(model.NewLocalGovernor));
                }
            }

            var governor = await _governorsReadService.GetGovernorAsync(model.ExistingGovernorId, User);

            var roles = new List <eLookupGovernorRole>
            {
                (eLookupGovernorRole)governor.RoleId
            };

            if (EnumSets.SharedGovernorRoles.Contains(governor.RoleId.Value))
            {
                var localEquivalent = RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId);
                if (localEquivalent != null)
                {
                    roles.Add(localEquivalent.Value);
                }
            }
            else
            {
                roles.AddRange(RoleEquivalence.GetEquivalentToLocalRole((eLookupGovernorRole)governor.RoleId));
            }

            var governors = (await _governorsReadService.GetSharedGovernorsAsync(model.Urn.Value, User)).Where(g => roles.Contains((eLookupGovernorRole)g.RoleId) && g.Id != model.ExistingGovernorId).ToList();

            model.NewLocalGovernor.DisplayPolicy = await _governorsReadService.GetEditorDisplayPolicyAsync((RoleEquivalence.GetLocalEquivalentToSharedRole((eLookupGovernorRole)governor.RoleId.Value) ?? (eLookupGovernorRole)governor.RoleId.Value), false, User);

            model.SharedGovernors = (await Task.WhenAll(governors.Select(async g => await SharedGovernorViewModel.MapFromGovernor(g, model.Urn.Value, _cachedLookupService)))).ToList();

            await PopulateSelectLists(model.NewLocalGovernor);

            await _layoutHelper.PopulateLayoutProperties(model, model.Urn, null, User);

            return(View(model));
        }
        public async Task <ActionResult> SelectSharedGovernor(int establishmentUrn, eLookupGovernorRole role)
        {
            var roleName  = (await _cachedLookupService.GovernorRolesGetAllAsync()).Single(x => x.Id == (int)role).Name;
            var governors = (await _governorsReadService.GetSharedGovernorsAsync(establishmentUrn, User)).Where(g => RoleEquivalence.GetEquivalentRole(role).Contains((eLookupGovernorRole)g.RoleId)).ToList();

            var sharedGovernors = governors.Select(async g => await SharedGovernorViewModel.MapFromGovernor(g, establishmentUrn, _cachedLookupService));

            var viewModel = new SelectSharedGovernorViewModel
            {
                Governors    = (await Task.WhenAll(sharedGovernors)).ToList(),
                GovernorType = roleName.ToLowerInvariant(),
            };

            await _layoutHelper.PopulateLayoutProperties(viewModel, establishmentUrn, null, User);

            return(View(viewModel));
        }