From 31ad6f14349da94d28c29c9d9bf62c4fa62cb71c Mon Sep 17 00:00:00 2001 From: enisn Date: Thu, 25 Feb 2021 16:15:56 +0300 Subject: [PATCH] CmsKit - Remove custom event & use pre-built event for BlogFeature --- .../CmsKit/Blogs/BlogFeatureChangedHandler.cs | 23 +++++++++++++++---- .../CmsKit/Blogs/BlogFeatureChangedEto.cs | 17 -------------- 2 files changed, 19 insertions(+), 21 deletions(-) delete mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs index c861c0eb91..6e5ee46a79 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureChangedHandler.cs +++ b/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.DependencyInjection; +using Volo.Abp.Domain.Entities.Events; using Volo.Abp.EventBus; namespace Volo.CmsKit.Blogs { - public class BlogFeatureChangedHandler : ILocalEventHandler, ITransientDependency + public class BlogFeatureChangedHandler : + ILocalEventHandler>, + ILocalEventHandler>, + ITransientDependency { protected IDistributedCache Cache { get; } @@ -15,9 +20,19 @@ namespace Volo.CmsKit.Blogs 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 eventData) + { + return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName); + } + + public Task HandleEventAsync(EntityUpdatedEventData eventData) + { + return RemoveFromCacheAsync(eventData.Entity.BlogId, eventData.Entity.FeatureName); } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs deleted file mode 100644 index 954c851d04..0000000000 --- a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/Blogs/BlogFeatureChangedEto.cs +++ /dev/null @@ -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; } - } -}