2011-12-29 13:55:51 -08:00
|
|
|
using System;
|
2010-01-23 23:21:08 +00:00
|
|
|
using JetBrains.Annotations;
|
2010-02-23 20:54:19 -08:00
|
|
|
using Orchard.Comments.Models;
|
2011-12-05 12:39:14 -08:00
|
|
|
using Orchard.Comments.Services;
|
2010-01-23 23:21:08 +00:00
|
|
|
using Orchard.ContentManagement.Drivers;
|
|
|
|
|
|
2010-03-03 23:31:42 -08:00
|
|
|
namespace Orchard.Comments.Drivers {
|
2010-01-23 23:21:08 +00:00
|
|
|
[UsedImplicitly]
|
2010-07-22 14:08:31 -07:00
|
|
|
public class CommentsContainerPartDriver : ContentPartDriver<CommentsContainerPart> {
|
2011-12-05 12:39:14 -08:00
|
|
|
private readonly ICommentService _commentService;
|
|
|
|
|
|
|
|
|
|
public CommentsContainerPartDriver(ICommentService commentService) {
|
|
|
|
|
_commentService = commentService;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-11 02:06:01 -07:00
|
|
|
protected override DriverResult Display(CommentsContainerPart part, string displayType, dynamic shapeHelper) {
|
2011-12-29 13:55:51 -08:00
|
|
|
|
2011-12-05 12:39:14 -08:00
|
|
|
var commentsForCommentedContent = _commentService.GetCommentsForCommentedContent(part.ContentItem.Id);
|
2011-12-29 13:55:51 -08:00
|
|
|
Func<int> pendingCount = () => commentsForCommentedContent.Where(x => x.Status == CommentStatus.Pending).Count();
|
2011-12-05 12:39:14 -08:00
|
|
|
|
2010-10-15 18:11:06 -07:00
|
|
|
return Combined(
|
2011-12-05 12:39:14 -08:00
|
|
|
|
2010-10-15 18:11:06 -07:00
|
|
|
ContentShape("Parts_Comments_Count",
|
2011-12-30 15:26:41 -08:00
|
|
|
() => shapeHelper.Parts_Comments_Count(CommentCount: commentsForCommentedContent.Count(), PendingCount: pendingCount)),
|
2010-10-15 18:11:06 -07:00
|
|
|
ContentShape("Parts_Comments_Count_SummaryAdmin",
|
2011-12-30 15:26:41 -08:00
|
|
|
() => shapeHelper.Parts_Comments_Count_SummaryAdmin(CommentCount: commentsForCommentedContent.Count(), PendingCount: pendingCount))
|
2010-10-15 18:11:06 -07:00
|
|
|
);
|
|
|
|
|
}
|
2010-01-23 23:21:08 +00:00
|
|
|
}
|
|
|
|
|
}
|