public ActionResult EditComment(EditCommentModel model) { var response = _commandBus.Send<EditComment, EditCommentResponse>(new EditComment { DateEdited = Common.CurrentTime(), CommentId = model.CommentId, Body = model.Body }); if (!string.IsNullOrEmpty(response.Error)) return CommonJsonResult(response.Error); var html = RenderView("_CommentBody", new CommentNode(_commentWrapper.Wrap(model.CommentId, _userContext.CurrentUser))); return Json(new { success = true, commentId = model.CommentId, // we don't render the whole comment, just the body. // this is because we want to leave the children in-tact on the ui html }); }
public ActionResult EditComment(EditCommentModel model) { if (!Request.IsAuthenticated) { return Json(new { success = false, error = "You must be logged in to edit a comment." }); } try { var response = _commandBus.Send<EditComment, EditCommentResponse>(new EditComment { DateEdited = Common.CurrentTime(), CommentId = model.CommentId, Body = model.Body }); if (!string.IsNullOrEmpty(response.Error)) { return Json(new { success = false, error = response.Error }); } var html = RenderView("_CommentBody", new CommentNode(_commentWrapper.Wrap(model.CommentId, _userContext.CurrentUser))); return Json(new { success = true, commentId = model.CommentId, // we don't render the whole comment, just the body. // this is because we want to leave the children in-tact on the ui html }); } catch (Exception ex) { // TODO: log return Json(new { success = false, error = "An unexpected error occured." }); } }