public ActionResult Edit([Bind(Include = "Id,Title,Description,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId")] Ticket ticket) { if (ModelState.IsValid) { //db.Entry(ticket).State = EntityState.Modified; //db.SaveChanges(); TicketHelper.Edit(ticket.Id, ticket.OwnerUserId, ticket.Title, ticket.Description, ticket.TicketTypeId, ticket.TicketPriorityId, ticket.TicketStatusId, ticket.AssignedToUserId); var modifiedTicket = db.Tickets.Find(ticket.Id); TicketNotificationHelper.AddNotification(modifiedTicket.Id, modifiedTicket.AssignedToUserId, NotificationType.ModifiedBy, User.Identity.GetUserName()); db.SaveChanges(); return(RedirectToAction("Index", new { userId = User.Identity.GetUserId() })); //return RedirectToAction("Index", "Projects", new { userId = User.Identity.GetUserId() }); } string roleId = db.Roles.FirstOrDefault(r => r.Name == "Developer").Id; var developers = db.Users.Where(u => u.Roles.Any(r => r.RoleId == roleId)); ViewBag.AssignedToUserId = new SelectList(developers, "Id", "Email", ticket.AssignedToUserId); //ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
public ActionResult Assign(int Id, string AssignedToUserId) { TicketHelper.Assign(Id, AssignedToUserId); var developers = UserHelper.GetUsersFromRole("Developer"); var projectId = db.Tickets.Find(Id).ProjectId; var developersOfProject = developers.Where(u => u.ProjectUsers.Any(pu => pu.ProjectId == projectId)).ToList(); ViewBag.AssignedToUserId = new SelectList(developersOfProject, "Id", "Email"); ViewBag.Id = Id; TicketNotificationHelper.AddNotification(Id, AssignedToUserId, NotificationType.AssignedBy, User.Identity.GetUserName()); db.SaveChanges(); db.Dispose(); return(RedirectToAction("Index", "Projects", new { userId = User.Identity.GetUserId() })); }