public ActionResult TicketAssign(string id) { ViewBag.UserId = id; var occupiedTickets = ticketHelper.ListUserTickets(id).Select(p => p.Id); var currentProjTix = ticketHelper.GetMyProjectTickets(id); ViewBag.AllTickets = new MultiSelectList(currentProjTix, "Id", "Title", occupiedTickets); return(View()); }
public ActionResult Index() { var dashboardData = new DashboardVM(); var userId = User.Identity.GetUserId(); var myRole = "Guest"; if (userId != null) { myRole = roleHelper.ListUserRoles(User.Identity.GetUserId()).FirstOrDefault(); } switch (myRole) { case "Admin": dashboardData.RecentProjects = db.Projects.Take(5).ToList(); dashboardData.RecentTickets = db.Tickets.OrderByDescending(tn => tn.Created).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.OrderByDescending(tn => tn.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.OrderByDescending(c => c.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.OrderByDescending(h => h.ChangedDate).Take(5).ToList(); break; case "Project Manager": dashboardData.RecentProjects = projectHelper.ListUserProjects(userId).Take(5).ToList(); dashboardData.RecentTickets = ticketHelper.GetMyProjectTickets(userId).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.Where(t => t.UserId == userId).OrderByDescending(tn => tn.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.Where(c => c.UserId == userId).OrderByDescending(com => com.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.Where(h => h.UserId == userId).OrderByDescending(his => his.ChangedDate).Take(5).ToList(); break; case "Developer": dashboardData.RecentProjects = projectHelper.ListUserProjects(userId).Take(5).ToList(); dashboardData.RecentTickets = db.Tickets.Where(t => t.AssignedToUserId == userId).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.Where(a => a.Ticket.AssignedToUserId == userId).OrderByDescending(att => att.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.Where(c => c.Ticket.AssignedToUserId == userId).OrderByDescending(com => com.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.Where(h => h.Ticket.AssignedToUserId == userId).OrderByDescending(his => his.ChangedDate).Take(5).ToList(); break; case "Submitter": dashboardData.RecentProjects = projectHelper.ListUserProjects(userId).Take(5).ToList(); dashboardData.RecentTickets = db.Tickets.Where(t => t.OwnerUserId == userId).Take(5).ToList(); dashboardData.AllUsers = db.Users.ToList(); dashboardData.RecentAttachments = db.TicketAttachments.Where(a => a.Ticket.OwnerUserId == userId).OrderByDescending(att => att.Created).Take(5).ToList(); dashboardData.RecentComments = db.TicketComments.Where(c => c.Ticket.OwnerUserId == userId).OrderByDescending(com => com.Created).Take(5).ToList(); dashboardData.RecentHistories = db.TicketHistories.Where(h => h.Ticket.OwnerUserId == userId).OrderByDescending(his => his.ChangedDate).Take(5).ToList(); break; default: ViewBag.Message = "You will not be able to see any data until you are assigned to a role."; break; } return(View(dashboardData)); }