|
|
|
@ -2,6 +2,8 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.Domain.Services; |
|
|
|
using Volo.Abp.EventBus.Distributed; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
|
|
|
|
namespace Volo.CmsKit.Blogs |
|
|
|
{ |
|
|
|
@ -11,12 +13,20 @@ namespace Volo.CmsKit.Blogs |
|
|
|
|
|
|
|
protected IDefaultBlogFeatureProvider DefaultBlogFeatureProvider { get; } |
|
|
|
|
|
|
|
protected IUnitOfWorkManager UnitOfWorkManager { get; } |
|
|
|
|
|
|
|
protected IDistributedEventBus EventBus { get; } |
|
|
|
|
|
|
|
public BlogFeatureManager( |
|
|
|
IBlogFeatureRepository blogFeatureRepository, |
|
|
|
IDefaultBlogFeatureProvider defaultBlogFeatureProvider) |
|
|
|
IDefaultBlogFeatureProvider defaultBlogFeatureProvider, |
|
|
|
IUnitOfWorkManager unitOfWorkManager, |
|
|
|
IDistributedEventBus eventBus) |
|
|
|
{ |
|
|
|
BlogFeatureRepository = blogFeatureRepository; |
|
|
|
DefaultBlogFeatureProvider = defaultBlogFeatureProvider; |
|
|
|
UnitOfWorkManager = unitOfWorkManager; |
|
|
|
EventBus = eventBus; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<List<BlogFeature>> GetListAsync(Guid blogId) |
|
|
|
@ -29,5 +39,29 @@ namespace Volo.CmsKit.Blogs |
|
|
|
|
|
|
|
return blogFeatures; |
|
|
|
} |
|
|
|
|
|
|
|
public async Task SetAsync(Guid blogId, string featureName, bool isEnabled) |
|
|
|
{ |
|
|
|
var blogFeature = await BlogFeatureRepository.FindAsync(blogId, featureName); |
|
|
|
if (blogFeature == null) |
|
|
|
{ |
|
|
|
var newBlogFeature = new BlogFeature(blogId, featureName, isEnabled); |
|
|
|
await BlogFeatureRepository.InsertAsync(newBlogFeature); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
blogFeature.IsEnabled = isEnabled; |
|
|
|
await BlogFeatureRepository.UpdateAsync(blogFeature); |
|
|
|
} |
|
|
|
|
|
|
|
await UnitOfWorkManager.Current.SaveChangesAsync(); |
|
|
|
|
|
|
|
await EventBus.PublishAsync(new BlogFeatureChangedEto |
|
|
|
{ |
|
|
|
BlogId = blogId, |
|
|
|
FeatureName = featureName, |
|
|
|
IsEnabled = isEnabled |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|