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));
        }
Exemple #2
0
        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);
        }
    }
Exemple #4
0
        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
            });
        }
Exemple #5
0
    public virtual async Task <List <BlogFeatureDto> > GetListAsync(Guid blogId)
    {
        var blogFeatures = await BlogFeatureRepository.GetListAsync(blogId);

        return(ObjectMapper.Map <List <BlogFeature>, List <BlogFeatureDto> >(blogFeatures));
    }