Browse Source

CmsKit - Remove custom event & use pre-built event for BlogFeature

pull/7845/head
enisn 6 years ago
parent
commit
31ad6f1434
  1. 23
      modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs
  2. 17
      modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs

23
modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs

@ -1,11 +1,16 @@
using System.Threading.Tasks; using System;
using System.Threading.Tasks;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
namespace Volo.CmsKit.Blogs namespace Volo.CmsKit.Blogs
{ {
public class BlogFeatureChangedHandler : ILocalEventHandler<BlogFeatureChangedEto>, ITransientDependency public class BlogFeatureChangedHandler :
ILocalEventHandler<EntityCreatedEventData<BlogFeature>>,
ILocalEventHandler<EntityUpdatedEventData<BlogFeature>>,
ITransientDependency
{ {
protected IDistributedCache<BlogFeatureCacheItem, BlogFeatureCacheKey> Cache { get; } protected IDistributedCache<BlogFeatureCacheItem, BlogFeatureCacheKey> Cache { get; }
@ -15,9 +20,19 @@ namespace Volo.CmsKit.Blogs
Cache = cache; Cache = cache;
} }
public async Task HandleEventAsync(BlogFeatureChangedEto eventData) public Task RemoveFromCacheAsync(Guid blogId, string featureName)
{ {
await Cache.RemoveAsync(new BlogFeatureCacheKey(eventData.BlogId, eventData.FeatureName)); return Cache.RemoveAsync(new BlogFeatureCacheKey(blogId, featureName));
}
public Task HandleEventAsync(EntityCreatedEventData<BlogFeature> eventData)
{
return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName);
}
public Task HandleEventAsync(EntityUpdatedEventData<BlogFeature> eventData)
{
return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName);
} }
} }
} }

17
modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.EventBus;
namespace Volo.CmsKit.Blogs
{
[EventName("CmsKit.Blogs.BlogFeature.Changed")]
public class BlogFeatureChangedEto
{
public Guid BlogId { get; set; }
public string FeatureName { get; set; }
public bool IsEnabled { get; set; }
}
}
Loading…
Cancel
Save