public ActionResult Edit(Comment comment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(comment).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.AuthorID = new SelectList(db.Users, "Id", "UserName", comment.AuthorID);
     ViewBag.TicketId = new SelectList(db.Tickets, "Id", "AuthorId", comment.TicketId);
     return View(comment);
 }
        public JsonResult CreateComment([DataSourceRequest] DataSourceRequest request, CommentViewModel comment)
        {
            if (comment != null && ModelState.IsValid)
            {
                var newComment = new Comment
                {
                    Content = comment.Content
                };

                this.Data.Comments.Add(newComment);
                this.Data.SaveChanges();
            }

            return Json(new[] { comment }.ToDataSourceResult(request, ModelState), JsonRequestBehavior.AllowGet);
        }
        public ActionResult PostComment(AddCommentModel commentModel)
        {
            if (ModelState.IsValid)
            {
                var username = this.User.Identity.GetUserName();
                var userId = this.User.Identity.GetUserId();

                var comment = new Comment()
                {
                    TicketId = commentModel.TicketId,
                    Content = commentModel.Content,
                    UserId = userId
                };

                this.Data.Comments.Add(comment);
                this.Data.SaveChanges();

                var viewModel = new CommentViewModel { AuthorName = username, Content = commentModel.Content };
                return PartialView("_CommentPartial", viewModel);
            }

            return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest, ModelState.Values.First().ToString());
        }
        public ActionResult Edit(Comment comment)
        {
            if (ModelState.IsValid)
            {
                this.Data.Context.Entry(comment).State = EntityState.Modified;
                this.Data.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(comment);
        }