Fixed comments total at /Admin/Blogs is always 0

Fixes #7838
This commit is contained in:
Jack Cheng
2017-09-21 12:22:42 -07:00
committed by Sébastien Ros
parent f7ddd1eb94
commit 7a734ec8bc
3 changed files with 7 additions and 1 deletions

View File

@@ -13,7 +13,7 @@ namespace Orchard.Comments.Drivers {
protected override DriverResult Display(CommentsContainerPart part, string displayType, dynamic shapeHelper) {
var commentsForCommentedContent = _commentService.GetCommentsForCommentedContent(part.ContentItem.Id);
var commentsForCommentedContent = _commentService.GetCommentsForContainer(part.ContentItem.Id);
Func<int> pendingCount = () => commentsForCommentedContent.Where(x => x.Status == CommentStatus.Pending).Count();
Func<int> approvedCount = () => commentsForCommentedContent.Where(x => x.Status == CommentStatus.Approved).Count();

View File

@@ -60,6 +60,11 @@ namespace Orchard.Comments.Services {
public Localizer T { get; set; }
public ILogger Logger { get; set; }
public IContentQuery<CommentPart, CommentPartRecord> GetCommentsForContainer(int id) {
return GetComments()
.Where(c => c.CommentedOnContainer == id);
}
public CommentPart GetComment(int id) {
return _orchardServices.ContentManager.Get<CommentPart>(id);
}

View File

@@ -8,6 +8,7 @@ namespace Orchard.Comments.Services {
IContentQuery<CommentPart, CommentPartRecord> GetComments(CommentStatus status);
IContentQuery<CommentPart, CommentPartRecord> GetCommentsForCommentedContent(int id);
IContentQuery<CommentPart, CommentPartRecord> GetCommentsForCommentedContent(int id, CommentStatus status);
IContentQuery<CommentPart, CommentPartRecord> GetCommentsForContainer(int id);
CommentPart GetComment(int id);
ContentItemMetadata GetDisplayForCommentedContent(int id);
ContentItem GetCommentedContent(int id);