public ActionResult Accelerate(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ticket ticket = db.Tickets.Find(id); if (ticket == null) { return(HttpNotFound()); } if (ticket.Accelerated == true) { return(RedirectToActionPermanent("Accelerated", new { id = ticket.TicketId })); } AccelerateTicketViewModel model = new AccelerateTicketViewModel { Id = ticket.TicketId, Accelerated = ticket.Accelerated, AccelerationComment = ticket.AccelerationComment, AccelerationDate = DateTime.Now, }; return(View(model)); }
public ActionResult Accelerate(int id, AccelerateTicketViewModel model) { if (ModelState.IsValid) { Ticket ticket = db.Tickets.Find(id); if (ticket == null) { return(HttpNotFound()); } ticket.AccelerationComment = model.AccelerationComment; ticket.Accelerated = true; ticket.AccelerationDate = DateTime.Now; db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
/// <summary> /// This action informs staff that ticket has been accelerated and connot be accelerated again. /// </summary> /// <param name="id">Ticket Id as a parameter</param> /// <returns></returns> public ActionResult Accelerated(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ticket ticket = db.Tickets.Find(id); if (ticket == null) { return(HttpNotFound()); } var model = new AccelerateTicketViewModel { Id = ticket.TicketId, AccelerationDate = ticket.AccelerationDate, }; return(View(model)); }