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);
            }
        }
Example #2
0
 public static ConfigurationItemEntity Create(string id, ConfigurationItemType type, string value)
 {
     return(new ConfigurationItemEntity
     {
         Id = id,
         Type = type,
         Value = value
     });
 }
Example #3
0
        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();
            }
        }
Example #5
0
        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);
        }
Example #6
0
 public ConfigurationItem this[ConfigurationItemType item]
 {
     get { return (ConfigurationItem)Dictionary[item]; }
     set { Dictionary[item] = value; }
 }
Example #7
0
 public bool IsConfigurationItemEnabled(ConfigurationItemType item)
 {
     return items[item].Enabled;
 }
Example #8
0
        //
        // Public methods
        //

        #region public bool IsConfigurationItemEnabled(ConfigurationItemType item)
        public bool IsConfigurationItemEnabled(ConfigurationItemType item)
        {
            return(items[item].Enabled);
        }
Example #9
0
 public ConfigurationItem this[ConfigurationItemType item]
 {
     get { return((ConfigurationItem)Dictionary[item]); }
     set { Dictionary[item] = value; }
 }