#19082: Fixing exception when resolving BlogPartArchiveHandler from a singleton

Work Item: 19082

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2012-10-08 16:21:14 -07:00
parent 63d749b326
commit 52aff140c4

View File

@@ -12,16 +12,15 @@ using Orchard.Data;
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
public class BlogPartArchiveHandler : ContentHandler {
private readonly WorkContext _workContext;
private readonly IWorkContextAccessor _workContextAccessor;
// contains the creation time of a blog part before it has been changed
private readonly Dictionary<BlogPostPart, DateTime> _previousCreatedUtc = new Dictionary<BlogPostPart,DateTime>();
public BlogPartArchiveHandler(
IRepository<BlogPartArchiveRecord> blogArchiveRepository,
IBlogPostService blogPostService,
WorkContext workContext) {
_workContext = workContext;
IWorkContextAccessor workContextAccessor) {
_workContextAccessor = workContextAccessor;
OnVersioning<BlogPostPart>((context, bp1, bp2) => {
var commonPart = bp1.As<CommonPart>();
@@ -44,7 +43,7 @@ namespace Orchard.Blogs.Handlers {
return;
// get the time zone for the current request
var timeZone = _workContext.CurrentTimeZone;
var timeZone = _workContextAccessor.GetContext().CurrentTimeZone;
var previousCreatedUtc = _previousCreatedUtc.ContainsKey(blogPostPart) ? _previousCreatedUtc[blogPostPart] : DateTime.MinValue;
previousCreatedUtc = TimeZoneInfo.ConvertTimeFromUtc(previousCreatedUtc, timeZone);