public ActionResult ManageProjectUsers() { ViewBag.Projects = new MultiSelectList(db.Projects, "Id", "Name"); ViewBag.Developers = new MultiSelectList(userRolesHelper.UsersInRole("Developer"), "Id", "FullName"); ViewBag.Submitters = new MultiSelectList(userRolesHelper.UsersInRole("Submitter"), "Id", "FullName"); ViewBag.DemoDevelopers = new MultiSelectList(userRolesHelper.UsersInRole("DemoDeveloper"), "Id", "FullName"); ViewBag.DemoSubmitters = new MultiSelectList(userRolesHelper.UsersInRole("DemoSubmitter"), "Id", "FullName"); if (User.IsInRole("Admin") || User.IsInRole("DemoAdmin")) { ViewBag.ProjectManagerId = new SelectList(userRolesHelper.UsersInRole("ProjectManager"), "Id", "FullName"); ViewBag.DemoProjectManagerId = new SelectList(userRolesHelper.UsersInRole("DemoProjectManager"), "Id", "FullName"); } // Create View Model for viewing users & their projects var myData = new List <UserProjectsListViewModel>(); UserProjectsListViewModel userVm = null; foreach (var user in db.Users.ToList()) { userVm = new UserProjectsListViewModel { Name = $"{user.LastName}, {user.FirstName}", ProjectNames = projectsHelper.ListUserProjects(user.Id).Select(p => p.Name).ToList(), Role = userRolesHelper.GetRoleName(user.Id) }; // if no projects, add N/A if (userVm.ProjectNames.Count() == 0) { userVm.ProjectNames.Add("N/A"); } myData.Add(userVm); } return(View(myData)); }