public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Description,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignToUserId")] Ticket ticket) { //Go out to the DB and grab the current record. These values will act as the "Old values" var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); if (ModelState.IsValid) { db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); //Send the old and new tickets in to check for History generation tixHelper.AddTicketHistory(oldTicket, ticket); //Send some relevant data in to generate some notificTIONS await tixHelper.GenerateNotifications(oldTicket, ticket); return(RedirectToAction("Index")); } ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); 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.TicketStatus, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
public ActionResult Edit([Bind(Include = "Id,Created,Title,Description,ProjectId,TicketStatusId,TicketTypeId,TicketPriorityId,AssignedToUserId")] Ticket ticket) { var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); if (ModelState.IsValid) { ticket.Updated = DateTime.Now; db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); //Send the old and new tickets in to check for History generation ticketHelper.AddTicketHistory(oldTicket, ticket); //Send some relevant data in to generate some notifications ticketHelper.AddTicketNotification(ticket.Id, oldTicket.AssignedToUserId, ticket.AssignedToUserId); return(RedirectToAction("Index")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignedToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); 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)); }