fixes #4977 Incorrect BlogPartArchive count

This commit is contained in:
Jeff
2015-04-27 16:20:23 +01:00
parent c9d30d6cc2
commit d3f5765f5b

View File

@@ -6,6 +6,7 @@ using Orchard.Blogs.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Data;
namespace Orchard.Blogs.Handlers {
@@ -25,16 +26,16 @@ namespace Orchard.Blogs.Handlers {
_workContextAccessor = workContextAccessor;
_contentManager = contentManager;
OnPublishing<BlogPostPart>((context, bp) => SavePreviousPublishDate(context.Id));
OnRemoving<BlogPostPart>((context, bp) => SavePreviousPublishDate(context.Id));
OnUnpublishing<BlogPostPart>((context, bp) => SavePreviousPublishDate(context.Id));
OnUpdating<CommonPart>((context, cp) => { if(context.ContentItem.Has<BlogPostPart>()) SavePreviousCreatedDate(context.Id);});
OnRemoving<BlogPostPart>((context, bp) => SavePreviousCreatedDate(context.Id));
OnUnpublishing<BlogPostPart>((context, bp) => SavePreviousCreatedDate(context.Id));
OnPublished<BlogPostPart>((context, bp) => IncreaseBlogArchive(bp));
OnUnpublished<BlogPostPart>((context, bp) => ReduceBlogArchive(bp));
OnRemoved<BlogPostPart>((context, bp) => ReduceBlogArchive(bp));
}
private void SavePreviousPublishDate(int contentItemId) {
private void SavePreviousCreatedDate(int contentItemId) {
if (_previousCreatedUtc.ContainsKey(contentItemId)) {
return;
}
@@ -44,8 +45,8 @@ namespace Orchard.Blogs.Handlers {
// retrieve the creation date when it was published
if (previousPublishedVersion != null) {
var versionCommonPart = previousPublishedVersion.As<ICommonPart>();
if (versionCommonPart.VersionCreatedUtc.HasValue) {
_previousCreatedUtc[contentItemId] = versionCommonPart.VersionCreatedUtc.Value;
if (versionCommonPart.CreatedUtc.HasValue) {
_previousCreatedUtc[contentItemId] = versionCommonPart.CreatedUtc.Value;
}
}
}