public ActionResult Index() { List <AdminUserViewModel> userList = new List <AdminUserViewModel>(); foreach (var user in db.Users.ToList()) { var model = new AdminUserViewModel(); model.User = user; model.role = userManager.ListUserRoles(user.Id).ToList(); model.projects = phelper.ListProjects(user.Id).ToList(); userList.Add(model); } return(View(userList)); }
//GET: Home/Dashboard/ public ActionResult Dashboard(int?Id, int?projectId) { DashboardViewModel model = new DashboardViewModel(); //get user Id var userId = User.Identity.GetUserId(); var user = db.Users.Find(userId); //filter list of projects according to user role if (User.IsInRole("Admin") || User.IsInRole("ProjectManager") || User.IsInRole("Developer") || User.IsInRole("Submitter")) { //list this user's projects ProjectsHelper phelper = new ProjectsHelper(db); var project = phelper.ListProjects(userId).ToList(); model.Projects = user.Projects.OrderByDescending(p => p.Created).ToList(); //list this user's tickets TicketsHelper helper = new TicketsHelper(db); model.Tickets = helper.GetUserTickets(userId); var ticket = helper.ListTickets(userId).ToList(); model.OpenTickets = user.Projects.SelectMany(p => p.Tickets).Where(t => t.Status.Status == "Open").ToList(); model.PendingTickets = user.Projects.SelectMany(p => p.Tickets).Where(t => t.Status.Status == "Pending").ToList(); model.ClosedTickets = user.Projects.SelectMany(p => p.Tickets).Where(t => t.Status.Status == "Closed").ToList(); } return(View(model)); }