public ActionResult AddNewComment(CommentModel model) { if (model.CommentDescription.Length < 2) return JsonErrorResult("Слишком короткий комментарий"); var comment = new CommentData { CreateDate = DateTime.UtcNow, Description = model.CommentDescription, Rate = default(int), Writer = new UserData { Id = CurrentUser.Id } }; Execute(() => _newsService.AddNewsComment(model.ContentId, comment)); FillCommentModel(model); return ModelIsValid ? (ActionResult)View("_CommentDataPartial", model) : JsonErrorResult(); }
public ActionResult DeleteComment(int? id, int? contentId, CommentSortEnum sortType) { Execute(() => _newsService.DeleteNewsComment(id.GetValueOrDefault(), CurrentUser.IsMainRole, CurrentUser.Id)); var model = new CommentModel { ContentId = contentId.GetValueOrDefault(), SortType = sortType }; FillCommentModel(model); return ModelIsValid ? (ActionResult)View("_CommentDataPartial", model) : JsonErrorResult(); }
public ActionResult NewsCommentFeed(int? id, CommentSortEnum sortType) { var model = new CommentModel { ContentId = id.GetValueOrDefault(), SortType = sortType }; FillCommentModel(model); return ModelIsValid ? (ActionResult)View("_CommentDataPartial", model) : JsonErrorResult(); }
private void FillCommentModel(CommentModel model) { var commentsWrap = Execute(() => _newsService.GetNewsComments(model.ContentId, model.SortType)) ?? new CommentsWrapper(); model.CopyFrom(commentsWrap); }
public ActionResult NewsCommentData(int? id) { var model = new CommentModel { ContentId = id.GetValueOrDefault() }; FillCommentModel(model); return View(model); }