public async Task <IConfigurationItem> GetAsync(ConfigurationItemType type, TransactionContext txContext = null) { using (var context = _contextFactory.CreateDataContext(txContext)) { var entity = await context.ConfigurationItems.SingleOrDefaultAsync(x => x.Type == type); return(entity); } }
public static ConfigurationItemEntity Create(string id, ConfigurationItemType type, string value) { return(new ConfigurationItemEntity { Id = id, Type = type, Value = value }); }
public async Task <ConfigurationItemResponseModel> GetItemAsync(ConfigurationItemType type) { var domainType = type.ToDomain(); if (domainType == null) { _log.Warning($"Configuration item type {type.ToString()} is not recognized"); return(null); } var item = await _configurationItemsRepository.GetAsync(domainType.Value); return(_mapper.Map <ConfigurationItemResponseModel>(item)); }
public async Task UpsertAsync(ConfigurationItemType type, string value, TransactionContext txContext = null) { using (var context = _contextFactory.CreateDataContext(txContext)) { var entity = await context.ConfigurationItems.SingleOrDefaultAsync(x => x.Type == type); if (entity == null) { entity = ConfigurationItemEntity.Create(Guid.NewGuid().ToString(), type, value); context.ConfigurationItems.Add(entity); } else { entity.Value = value; } await context.SaveChangesAsync(); } }
public async Task GetNextWalletLinkingFeeAsync_UsesCorrespondingConfigurationItemType(int approvalsCounter, ConfigurationItemType expectedConfigurationItemType) { _linkCountersRepositoryMock .Setup(x => x.GetAsync(It.IsAny <string>(), null)) .ReturnsAsync(new WalletLinkingRequestsCounterEntity { ApprovalsCounter = approvalsCounter }); var configurationItemType = ConfigurationItemType.FirstTimeLinkingFee; _configurationItemsRepositoryMock .Setup(x => x.GetAsync(It.IsAny <ConfigurationItemType>(), null)) .Callback <ConfigurationItemType, TransactionContext>((type, txContext) => configurationItemType = type) .ReturnsAsync(new ConfigurationItemEntity { Value = "whatever" }); var sut = CreateSutInstance(); await sut.GetNextWalletLinkingFeeAsync(Guid.Parse(FakeCustomerId)); Assert.Equal(expectedConfigurationItemType, configurationItemType); }
public ConfigurationItem this[ConfigurationItemType item] { get { return (ConfigurationItem)Dictionary[item]; } set { Dictionary[item] = value; } }
public bool IsConfigurationItemEnabled(ConfigurationItemType item) { return items[item].Enabled; }
// // Public methods // #region public bool IsConfigurationItemEnabled(ConfigurationItemType item) public bool IsConfigurationItemEnabled(ConfigurationItemType item) { return(items[item].Enabled); }
public ConfigurationItem this[ConfigurationItemType item] { get { return((ConfigurationItem)Dictionary[item]); } set { Dictionary[item] = value; } }