private async Task SetCacheItemsAsync( string providerName, string providerKey, string currentName, FeatureValueCacheItem currentCacheItem) { var featureDefinitions = FeatureDefinitionManager.GetAll(); var featuresDictionary = (await FeatureValueRepository.GetListAsync(providerName, providerKey)) .ToDictionary(s => s.Name, s => s.Value); var cacheItems = new List <KeyValuePair <string, FeatureValueCacheItem> >(); foreach (var featureDefinition in featureDefinitions) { var featureValue = featuresDictionary.GetOrDefault(featureDefinition.Name); cacheItems.Add( new KeyValuePair <string, FeatureValueCacheItem>( CalculateCacheKey(featureDefinition.Name, providerName, providerKey), new FeatureValueCacheItem(featureValue) ) ); if (featureDefinition.Name == currentName) { currentCacheItem.Value = featureValue; } } await Cache.SetManyAsync(cacheItems, considerUow : true); }
public virtual async Task DeleteAsync(string name, string providerName, string providerKey) { var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); if (featureValue != null) { await FeatureValueRepository.DeleteAsync(featureValue); } }
public async Task DeleteAsync(string name, string providerName, string providerKey) { var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey).ConfigureAwait(false); if (featureValue != null) { await FeatureValueRepository.DeleteAsync(featureValue).ConfigureAwait(false); } }
public virtual async Task DeleteAsync(string name, string providerName, string providerKey) { var featureValues = await FeatureValueRepository.FindAllAsync(name, providerName, providerKey); foreach (var featureValue in featureValues) { await FeatureValueRepository.DeleteAsync(featureValue); } }
public AssemblyService(ComputerShopContext context) { categoryRepo = new CategoryRepository(context); productRepo = new ProductRepository(context); assemblyRepo = new AssemblyRepository(context); featureRepo = new FeatureRepository(context); featuresForCategoryRepo = new FeaturesForCategoryRepository(context); featureValueRepo = new FeatureValueRepository(context); userRepo = new UserRepository(context); }
public virtual async Task DeleteAsync(string name, string providerName, string providerKey) { var featureValues = await FeatureValueRepository.FindAllAsync(name, providerName, providerKey); foreach (var featureValue in featureValues) { await FeatureValueRepository.DeleteAsync(featureValue); await Cache.RemoveAsync(CalculateCacheKey(name, providerName, providerKey), considerUow : true); } }
public AdminService(ComputerShopContext context) { groupRepo = new GroupRepository(context); categoryRepo = new CategoryRepository(context); producentRepo = new ProducentRepository(context); featureRepo = new FeatureRepository(context); featureValueRepo = new FeatureValueRepository(context); featureForCategoryRepo = new FeaturesForCategoryRepository(context); productRepo = new ProductRepository(context); featureValueRepo = new FeatureValueRepository(context); userRepo = new UserRepository(context); featureValueForProductRepo = new FeatureValueForProductRepository(context); }
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey) { var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); if (featureValue == null) { featureValue = new FeatureValue(GuidGenerator.Create(), name, value, providerName, providerKey); await FeatureValueRepository.InsertAsync(featureValue); } else { featureValue.Value = value; await FeatureValueRepository.UpdateAsync(featureValue); } }
public virtual async Task SetAsync(string name, string value, string providerName, string providerKey) { var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); if (featureValue == null) { featureValue = new FeatureValue(GuidGenerator.Create(), name, value, providerName, providerKey); await FeatureValueRepository.InsertAsync(featureValue); } else { featureValue.Value = value; await FeatureValueRepository.UpdateAsync(featureValue); } await Cache.SetAsync(CalculateCacheKey(name, providerName, providerKey), new FeatureValueCacheItem(featureValue?.Value), considerUow : true); }
public async Task SetAsync() { // Arrange (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, TestEditionIds.Regular.ToString())).Value.ShouldBe(true.ToString().ToLowerInvariant()); // Act await FeatureManagementStore.SetAsync(TestFeatureDefinitionProvider.SocialLogins, false.ToString().ToUpperInvariant(), EditionFeatureValueProvider.ProviderName, TestEditionIds.Regular.ToString()); // Assert (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, TestEditionIds.Regular.ToString())).Value.ShouldBe(false.ToString().ToUpperInvariant()); }
public async Task DeleteAsync() { // Arrange (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, TestEditionIds.Regular.ToString())).ShouldNotBeNull(); // Act await FeatureManagementStore.DeleteAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, TestEditionIds.Regular.ToString()); // Assert (await FeatureValueRepository.FindAsync(TestFeatureDefinitionProvider.SocialLogins, EditionFeatureValueProvider.ProviderName, TestEditionIds.Regular.ToString())).ShouldBeNull(); }
protected virtual async Task <FeatureValueCacheItem> GetCacheItemAsync(string name, string providerName, string providerKey) { var cacheKey = CalculateCacheKey(name, providerName, providerKey); var cacheItem = await Cache.GetAsync(cacheKey); if (cacheItem != null) { return(cacheItem); } var featureValue = await FeatureValueRepository.FindAsync(name, providerName, providerKey); cacheItem = new FeatureValueCacheItem(featureValue?.Value); await Cache.SetAsync( cacheKey, cacheItem ); return(cacheItem); }