// GET: users/{accountId}/projects/{projectId}/tickets/{ticketId}/ticketcomments/new public ActionResult New(string accountId, int projectId, int ticketId) { NewTicketCommentViewModel model = new NewTicketCommentViewModel(); ViewBag.accountId = accountId; ViewBag.projectId = projectId; ViewBag.ticketId = ticketId; return(View(model)); }
public ActionResult Create(string username, int projectId, int ticketId, NewTicketCommentViewModel model) { if (ModelState.IsValid) { Ticket ticket = db.Tickets.FirstOrDefault(t => t.ID == ticketId); TicketComment ticketComment = new TicketComment(); ticketComment.Ticket = ticket; ticketComment.AspNetUser = db.AspNetUsers.FirstOrDefault(u => u.UserName == User.Identity.Name); ticketComment.Created = DateTimeOffset.Now; ticketComment.Comment = model.Comment; ticketComment.UserID = ticketComment.AspNetUser.Id; db.TicketComments.Add(ticketComment); db.SaveChanges(); TempData["tab"] = "#comments-3"; return(RedirectToAction("Show", "Tickets", new { accountUsername = username, projectId = projectId, id = ticketId })); } return(View("Show", model)); }