public virtual ActionResult CommentUpdate(AdminBlogCommentModel model) { var comment = _blogService.GetBlogCommentById(model.Id); if (comment == null) { throw new ArgumentException("No comment found with the specified id"); } var previousIsApproved = comment.IsApproved; comment.IsApproved = model.IsApproved; _blogService.UpdateBlogPostComment(comment); return(new NullJsonResult()); }
public virtual ActionResult Comments(int?filterByBlogPostId, DataSourceRequest command, AdminBlogCommentListModel model) { var createdOnFromValue = model.CreatedOnFrom == null ? null : (DateTime?)ConvertToUtcTime(model.CreatedOnFrom.Value, INDIAN_ZONE_C); var createdOnToValue = model.CreatedOnTo == null ? null : (DateTime?)ConvertToUtcTime(model.CreatedOnTo.Value, INDIAN_ZONE_C).AddDays(1); bool?approved = null; if (model.SearchApprovedId > 0) { approved = model.SearchApprovedId == 1; } var comments = _blogService.GetAllComments(null, filterByBlogPostId, approved, createdOnFromValue, createdOnToValue, model.SearchText); var gridModel = new DataSourceResult { Data = comments.PagedForCommand(command).Select(blogComment => { var commentModel = new AdminBlogCommentModel(); commentModel.Id = blogComment.Id; commentModel.BlogPostId = blogComment.BlogPostId; commentModel.BlogPostTitle = blogComment.BlogPost.Title; commentModel.VisitorId = blogComment.VisitorId; var customer = blogComment.Visitor; commentModel.VisitorInfo = (customer != null) ? customer.Email : string.Empty; commentModel.CreatedOn = ConvertToUserTime(blogComment.CreatedOnUtc, DateTimeKind.Utc); commentModel.Comment = blogComment.CommentText; commentModel.IsApproved = blogComment.IsApproved; return(commentModel); }), Total = comments.Count, }; return(Json(gridModel)); }