protected virtual async Task <BlogFeatureCacheItem> GetOrDefaultFroRepositoryAsync(Guid blogId, string featureName) { var feature = await BlogFeatureRepository.FindAsync(blogId, featureName); var blogFeature = feature ?? new BlogFeature(blogId, featureName); return(ObjectMapper.Map <BlogFeature, BlogFeatureCacheItem>(blogFeature)); }
public async Task <List <BlogFeature> > GetListAsync(Guid blogId) { var blogFeatures = await BlogFeatureRepository.GetListAsync(blogId); var defaultFeatures = await DefaultBlogFeatureProvider.GetDefaultFeaturesAsync(blogId); defaultFeatures.ForEach(x => blogFeatures.AddIfNotContains(x)); return(blogFeatures); }
public async Task SetIfNotSetAsync(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); } }
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 }); }
public virtual async Task <List <BlogFeatureDto> > GetListAsync(Guid blogId) { var blogFeatures = await BlogFeatureRepository.GetListAsync(blogId); return(ObjectMapper.Map <List <BlogFeature>, List <BlogFeatureDto> >(blogFeatures)); }