Exemple #1
0
        private async Task CreateDummyExchagneRateData(DateRange dateRange, List <string> allCurrencies)
        {
            var dummyData = new List <CurrencyExchageRateApiResponse>();

            while (dateRange.StartTime < dateRange.EndTime)
            {
                Console.WriteLine(dateRange.StartTime);

                var newEurData = new CurrencyExchageRateApiResponse
                {
                    BaseCurrency = Currency.EUR.ToString(),
                    Rates        = GenerateDummyRates(allCurrencies),
                    CreateTime   = dateRange.StartTime
                };

                var newUsdData = new CurrencyExchageRateApiResponse
                {
                    BaseCurrency = Currency.USD.ToString(),
                    Rates        = GenerateDummyRates(allCurrencies),
                    CreateTime   = dateRange.StartTime
                };
                await InsertDataToDb(newEurData);
                await InsertDataToDb(newUsdData);

                dateRange.StartTime = dateRange.StartTime.AddDays(1);
            }
        }
Exemple #2
0
 private async Task InsertDataToDb(CurrencyExchageRateApiResponse source)
 {
     foreach (var item in source.Rates)
     {
         var newData = new CurrencyExchangeRate
         {
             SourceCurrency = item.Key,
             TargetCurrency = source.BaseCurrency,
             ExchangeRate   = item.Value,
             Date           = source.CreateTime
         };
         await _CurrencyExchangeRateRepository.InsertDataAsync(newData);
     }
 }