public JsonResult UpdateComment([DataSourceRequest] DataSourceRequest request, CommentViewModel comment)
        {
            var existingComment = this.Data.Comments.All().FirstOrDefault(c => c.Id == comment.Id);

            if (comment != null && ModelState.IsValid)
            {
                existingComment.Content = comment.Content;
                this.Data.SaveChanges();
            }

            return Json((new[] { comment }.ToDataSourceResult(request, ModelState)), JsonRequestBehavior.AllowGet);
        }
        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());
        }