public virtual ActionResult EditComment(string keyName, int id) { Ticket ticket = _ticketRepo.GetTicketByKey(keyName); Comment comment = _ticketRepo.GetCommentById(id); if (ticket == null || comment == null || comment.TicketId != ticket.Id || comment.UserId != 1) { return RedirectToAction(MVC.Error.InvalidAction()); } CommentCreateEditModel viewData = new CommentCreateEditModel() { Comment = comment }; return View(viewData); }
public virtual ActionResult CreateComment(string keyName, Comment comment) { Ticket ticket = _ticketRepo.GetTicketByKey(keyName); if (ticket == null) { return RedirectToAction(MVC.Error.InvalidAction()); } if (ModelState.IsValid) { comment.Created = DateTime.Now; comment.Modified = DateTime.Now; comment.UserId = Auth.CurrentUser.Id; comment.TicketId = ticket.Id; _ticketRepo.Save(comment); return RedirectToAction(MVC.Ticket.TicketDetails(keyName)); } CommentCreateEditModel viewData = new CommentCreateEditModel() { Comment = comment }; return View(viewData); }