public ActionResult Index() { var userId = User.Identity.GetUserId(); var user = db.Users.Find(userId); var projects = helper.ListUserProjects(userId); var tickets = new List <Ticket>(); if (User.IsInRole("Admin")) { return(View(db.Tickets.ToList())); } else if (User.IsInRole("Project Manager")) { foreach (var p in projects) { foreach (var t in p.Tickets) { tickets.Add(t); } } return(View(tickets)); } else if (User.IsInRole("Developer")) { return(View(db.Tickets.Where(t => t.AssignedToUserId == userId).ToList())); } else if (User.IsInRole("Submitter")) { return(View(db.Tickets.Where(t => t.OwnerUserId == userId).ToList())); } return(View(tickets)); }
public ActionResult ProjectList() { var user = User.Identity.GetUserId(); var projects = helper.ListUserProjects(user); return(View(projects.ToList())); }
public ActionResult Userprojects() { if (ModelState.IsValid) { var id = User.Identity.GetUserId(); ProjectAssignHelper helper = new ProjectAssignHelper(); var result = helper.ListUserProjects(id); return(View(result)); } ViewBag.UserTimeZone = db.Users.Find(User.Identity.GetUserId()).TimeZone; return(View()); }
public ActionResult Create() { ProjectAssignHelper helper = new ProjectAssignHelper(); var user = db.Users.Find(User.Identity.GetUserId()); ViewBag.ProjectId = new SelectList(helper.ListUserProjects(user.Id), "Id", "Title"); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name"); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name"); return(View()); }
public ActionResult Index() { if (Request.IsAuthenticated) { ViewBag.UserTimeZone = db.Users.Find(User.Identity.GetUserId()).TimeZone; var userId = User.Identity.GetUserId(); var userProjects = helper.ListUserProjects(userId); return(View(userProjects.Where(p => p.Archived == false).OrderByDescending(p => p.Created))); } else { return(View(db.Projects.Where(p => p.Archived == false).OrderByDescending(p => p.Created))); } }
public ActionResult Index() { if (User.IsInRole("Admin")) { var tickets = db.Tickets.Include(t => t.AssignedToUser).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); return(View(tickets.ToList())); } else if (User.IsInRole("Submitter")) { var user = db.Users.Find(User.Identity.GetUserId()).Id; var tickets = db.Tickets.Where(t => t.OwnerUserId == user).Include(t => t.AssignedToUser).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); return(View(tickets.ToList())); } else if (User.IsInRole("Developer")) { var user = db.Users.Find(User.Identity.GetUserId()).Id; var tickets = db.Tickets.Where(t => t.AssignedToUserId == user).Include(t => t.AssignedToUser).Include(t => t.OwnerUser).Include(t => t.Project).Include(t => t.TicketPriority).Include(t => t.TicketStatus).Include(t => t.TicketType); return(View(tickets.ToList())); } else if (User.IsInRole("Project Manager")) { var tickets = new List <Ticket>(); var myProjects = helper.ListUserProjects(User.Identity.GetUserId()); foreach (var project in myProjects) { foreach (var ticket in project.Tickets) { tickets.Add(ticket); } } return(View(tickets.ToList())); } else { return(View()); } }
public ActionResult Index() { var id = User.Identity.GetUserId(); ProjectAssignHelper helper = new ProjectAssignHelper(); var result = helper.ListUserProjects(id); ViewBag.UserTimeZone = db.Users.Find(User.Identity.GetUserId()).TimeZone; var thisMonth = System.DateTime.Now; var lastMonth = System.DateTime.Now.AddMonths(-1); var monthsAgo2 = System.DateTime.Now.AddMonths(-2); var monthsAgo3 = System.DateTime.Now.AddMonths(-3); var monthsAgo4 = System.DateTime.Now.AddMonths(-4); var monthsAgo5 = System.DateTime.Now.AddMonths(-5); ViewBag.ThisMonth = thisMonth.ToString("MMMM"); ViewBag.LastMonth = lastMonth.ToString("MMMM"); ViewBag.MonthsAgo2 = monthsAgo2.ToString("MMMM"); ViewBag.MonthsAgo3 = monthsAgo3.ToString("MMMM"); ViewBag.MonthsAgo4 = monthsAgo4.ToString("MMMM"); ViewBag.MonthsAgo5 = monthsAgo5.ToString("MMMM"); ViewBag.TicketsAddedThisMonth = db.Tickets.Where(t => t.Created.Month == thisMonth.Month && t.Created.Year == thisMonth.Year).Count(); ViewBag.TicketsAddedLastMonth = db.Tickets.Where(t => t.Created.Month == lastMonth.Month && t.Created.Year == lastMonth.Year).Count(); ViewBag.TicketsAdded2MonthsAgo = db.Tickets.Where(t => t.Created.Month == monthsAgo2.Month && t.Created.Year == monthsAgo2.Year).Count(); ViewBag.TicketsAdded3MonthsAgo = db.Tickets.Where(t => t.Created.Month == monthsAgo3.Month && t.Created.Year == monthsAgo3.Year).Count(); ViewBag.TicketsAdded4MonthsAgo = db.Tickets.Where(t => t.Created.Month == monthsAgo4.Month && t.Created.Year == monthsAgo4.Year).Count(); ViewBag.TicketsAdded5MonthsAgo = db.Tickets.Where(t => t.Created.Month == monthsAgo5.Month && t.Created.Year == monthsAgo5.Year).Count(); var completedThisMonth = new List <Ticket>(); var completedLastMonth = new List <Ticket>(); var completed2MonthsAgo = new List <Ticket>(); var completed3MonthsAgo = new List <Ticket>(); var completed4MonthsAgo = new List <Ticket>(); var completed5MonthsAgo = new List <Ticket>(); var completedTickets = db.Tickets.Where(t => t.TicketStatus.Name == "Completed").ToList(); foreach (var ticket in completedTickets) { var ticketCompletedHistory = ticket.Histories.Last(t => t.Property == "Status" && t.NewValue == "Completed"); if (ticketCompletedHistory != null) { if (ticketCompletedHistory.Created.Month == thisMonth.Month && ticketCompletedHistory.Created.Year == thisMonth.Year) { completedThisMonth.Add(ticket); } else if (ticketCompletedHistory.Created.Month == lastMonth.Month && ticketCompletedHistory.Created.Year == lastMonth.Year) { completedLastMonth.Add(ticket); } else if (ticketCompletedHistory.Created.Month == monthsAgo2.Month && ticketCompletedHistory.Created.Year == monthsAgo2.Year) { completed2MonthsAgo.Add(ticket); } else if (ticketCompletedHistory.Created.Month == monthsAgo3.Month && ticketCompletedHistory.Created.Year == monthsAgo3.Year) { completed3MonthsAgo.Add(ticket); } else if (ticketCompletedHistory.Created.Month == monthsAgo4.Month && ticketCompletedHistory.Created.Year == monthsAgo4.Year) { completed4MonthsAgo.Add(ticket); } else if (ticketCompletedHistory.Created.Month == monthsAgo5.Month && ticketCompletedHistory.Created.Year == monthsAgo5.Year) { completed5MonthsAgo.Add(ticket); } } } ViewBag.TicketsCompletedThisMonth = completedThisMonth.Count(); ViewBag.TicketsCompletedLastMonth = completedLastMonth.Count(); ViewBag.TicketsCompleted2MonthsAgo = completed2MonthsAgo.Count(); ViewBag.TicketsCompleted3MonthsAgo = completed3MonthsAgo.Count(); ViewBag.TicketsCompleted4MonthsAgo = completed4MonthsAgo.Count(); ViewBag.TicketsCompleted5MonthsAgo = completed5MonthsAgo.Count(); return(View(result)); }
// GET: Tickets/Edit/5 public ActionResult Edit(int?id) { Ticket ticket = db.Tickets.Find(id); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (User.IsInRole("Admin") || User.IsInRole("ProjectManager")) { ViewBag.TicketStatusId = new SelectList(db.TicketStatus, "Id", "Name", ticket.TicketStatusId); } else { ViewBag.TicketStatusId = new SelectList(new[] { ticket.TicketStatus }, "Id", "Name", ticket.TicketStatusId); } var user = db.Users.Find(User.Identity.GetUserId()); ProjectAssignHelper helper = new ProjectAssignHelper(); UserRoleHelper userhelper = new UserRoleHelper(); if (ticket == null) { return(HttpNotFound()); } List <ApplicationUser> devlist = new List <ApplicationUser>(); var projectdev = helper.ListUsersOnProject(ticket.ProjectId); foreach (var dev in projectdev) { if (userhelper.IsUserInRole(dev.Id, "Developer") == true) { devlist.Add(dev); } } ViewBag.AssignToUserId = new SelectList(devlist, "Id", "FirstName", ticket.AssignToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(helper.ListUserProjects(user.Id), "Id", "Title"); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatus, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); if (User.IsInRole("Admin")) { return(View(ticket)); } else if (User.IsInRole("ProjectManager")) { if (helper.IsUserOnProject(user.Id, ticket.ProjectId) == true) //defaults to true, == true not necessary { return(View(ticket)); } } else if (User.IsInRole("Developer") && ticket.AssignToUserId == user.Id) { return(View(ticket)); } else if (User.IsInRole("Submitter") && ticket.OwnerUserId == user.Id) { return(View(ticket)); } else { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Tickets", null)); }