From 0b0afcc95fdeef37f7f27bb9e14239d0b130f6a1 Mon Sep 17 00:00:00 2001 From: enisn Date: Mon, 22 Feb 2021 18:30:30 +0300 Subject: [PATCH] CmsKit - Refactor BlogFeatureAppService.cs --- .../Volo/CmsKit/Blogs/BlogFeatureAppService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs index cddb805c5c..a1671b93c9 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Common.Application/Volo/CmsKit/Blogs/BlogFeatureAppService.cs @@ -8,9 +8,9 @@ namespace Volo.CmsKit.Blogs { public class BlogFeatureAppService : CmsKitAppServiceBase, IBlogFeatureAppService { - protected IBlogFeatureRepository BlogFeatureRepository { get; } + protected virtual IBlogFeatureRepository BlogFeatureRepository { get; } - protected IBlogFeatureCacheManager BlogFeatureCacheManager { get; } + protected virtual IBlogFeatureCacheManager BlogFeatureCacheManager { get; } public BlogFeatureAppService( IBlogFeatureRepository blogFeatureRepository, @@ -20,17 +20,17 @@ namespace Volo.CmsKit.Blogs BlogFeatureCacheManager = blogFeatureCacheManager; } - public Task GetOrDefaultAsync(Guid blogId, string featureName) + public virtual Task GetOrDefaultAsync(Guid blogId, string featureName) { return BlogFeatureCacheManager .AddOrGetAsync( blogId, featureName, - ()=> GetOrDefaultFromDatabaseAsync(blogId, featureName) + ()=> GetOrDefaultFroRepositoryAsync(blogId, featureName) ); } - private async Task GetOrDefaultFromDatabaseAsync(Guid blogId, string featureName) + protected virtual async Task GetOrDefaultFroRepositoryAsync(Guid blogId, string featureName) { var feature = await BlogFeatureRepository.FindAsync(blogId, featureName); var blogFeature = feature ?? new BlogFeature(blogId, featureName);