public RoleProfilesViewModel(bool isWorkforceManager, bool isWorkforceContributor, AllRoleProfilesViewModel allRoleProfiles, MyRoleProfilesViewModel myRoleProfiles) { IsWorkforceManager = isWorkforceManager; IsWorkforceContributor = isWorkforceContributor; MyRoleProfilesViewModel = myRoleProfiles; AllRoleProfilesViewModel = allRoleProfiles; }
public IActionResult ViewRoleProfiles(string tabname, string?searchString = null, string sortBy = RoleProfileSortByOptionTexts.RoleProfileName, string sortDirection = BaseRoleProfilesPageViewModel.AscendingText, int page = 1 ) { var adminId = GetAdminID(); var isWorkforceManager = GetIsWorkforceManager(); var isWorkforceContributor = GetIsWorkforceContributor(); IEnumerable <RoleProfile> roleProfiles; if (tabname == "All") { roleProfiles = roleProfileService.GetAllRoleProfiles(adminId); } else { if (!isWorkforceContributor && !isWorkforceManager) { return(RedirectToAction("ViewRoleProfiles", "RoleProfiles", new { tabname = "All" })); } roleProfiles = roleProfileService.GetRoleProfilesForAdminId(adminId); } if (roleProfiles == null) { logger.LogWarning($"Attempt to display role profiles for admin {adminId} returned null."); return(StatusCode(403)); } MyRoleProfilesViewModel myRoleProfiles; AllRoleProfilesViewModel allRoleProfiles; if (tabname == "Mine") { myRoleProfiles = new MyRoleProfilesViewModel( roleProfiles, searchString, sortBy, sortDirection, page, isWorkforceManager); allRoleProfiles = new AllRoleProfilesViewModel( new List <RoleProfile>(), searchString, sortBy, sortDirection, page ); } else { allRoleProfiles = new AllRoleProfilesViewModel( roleProfiles, searchString, sortBy, sortDirection, page); myRoleProfiles = new MyRoleProfilesViewModel( new List <RoleProfile>(), searchString, sortBy, sortDirection, page, isWorkforceManager ); } var currentTab = tabname == "All" ? RoleProfilesTab.AllRoleProfiles : RoleProfilesTab.MyRoleProfiles; RoleProfilesViewModel?model = new RoleProfilesViewModel( isWorkforceManager, isWorkforceContributor, allRoleProfiles, myRoleProfiles, currentTab ); return(View("Index", model)); }