public ActionResult Details(int id, CommentDetailsOptions options) { // Default options if (options == null) { options = new CommentDetailsOptions(); } // Filtering IContentQuery <CommentPart, CommentPartRecord> comments; try { switch (options.Filter) { case CommentDetailsFilter.All: comments = _commentService.GetCommentsForCommentedContent(id); break; case CommentDetailsFilter.Approved: comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Approved); break; case CommentDetailsFilter.Pending: comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Pending); break; case CommentDetailsFilter.Spam: comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Spam); break; default: throw new ArgumentOutOfRangeException(); } var entries = comments.List().Select(comment => CreateCommentEntry(comment.Record)).ToList(); var model = new CommentsDetailsViewModel { Comments = entries, Options = options, DisplayNameForCommentedItem = _commentService.GetDisplayForCommentedContent(id) == null ? "" : _commentService.GetDisplayForCommentedContent(id).DisplayText, CommentedItemId = id, CommentsClosedOnItem = _commentService.CommentsDisabledForCommentedContent(id), }; return(View(model)); } catch (Exception exception) { this.Error(exception, T("Listing comments failed: {0}", exception.Message), Logger, Services.Notifier); return(RedirectToAction("Index")); } }
public ActionResult Details(int id, CommentDetailsOptions options) { // Default options if (options == null) { options = new CommentDetailsOptions(); } // Filtering IContentQuery <CommentPart, CommentPartRecord> comments; switch (options.Filter) { case CommentDetailsFilter.All: comments = _commentService.GetCommentsForCommentedContent(id); break; case CommentDetailsFilter.Approved: comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Approved); break; case CommentDetailsFilter.Pending: comments = _commentService.GetCommentsForCommentedContent(id, CommentStatus.Pending); break; default: throw new ArgumentOutOfRangeException(); } var entries = comments.List().Select(comment => CreateCommentEntry(comment)).ToList(); var model = new CommentsDetailsViewModel { Comments = entries, Options = options, DisplayNameForCommentedItem = _commentService.GetDisplayForCommentedContent(id) == null ? "" : _commentService.GetDisplayForCommentedContent(id).DisplayText, CommentedItemId = id, CommentsClosedOnItem = _commentService.CommentsDisabledForCommentedContent(id), }; return(View(model)); }