private async Task StoreCurencyRates(IEnumerable <ExchangeRate> currencyRates, DateTime date)
        {
            _logger.LogDebug($"StoreCurencyRates: {currencyRates.Count()}");
            if (currencyRates.Any())
            {
                try
                {
                    var filteredEntity = currencyRates
                                         .Where(x => !string.IsNullOrEmpty(x.Currency) &&
                                                (x.Currency.Equals(CurrencyRateConstants.CurrencyEUR, StringComparison.OrdinalIgnoreCase) ||
                                                 x.Currency.Equals(CurrencyRateConstants.CurrencyUSD, StringComparison.OrdinalIgnoreCase))).ToArray();

                    var entityToInsert = filteredEntity
                                         .Select(x => new CurrencyRateInsertEntity
                    {
                        Date            = date,
                        BaseCurrency    = x.BaseCurrency,
                        ToCurrency      = x.Currency,
                        SaleRateNBU     = x.SaleRateNB,
                        PurchaseRateNBU = x.PurchaseRateNB,
                        SaleRatePB      = (x.SaleRate ?? x.SaleRateNB),
                        PurchaseRatePB  = (x.PurchaseRate ?? x.PurchaseRateNB)
                    })
                                         .ToList();

                    _logger.LogDebug($"Trying to insert {entityToInsert.Count} entities");
                    await _currencyRateRepository.AddCurrencyRates(entityToInsert);
                }
                catch (Exception e)
                {
                    _logger.LogError(e.StackTrace);
                }
            }
        }
 private async Task StoreCurencyRates(IEnumerable <ExchangeRate> currencyRates, DateTime date)
 {
     if (currencyRates.Any())
     {
         var entityToInsert = currencyRates
                              .Where(x => !string.IsNullOrEmpty(x.Currency) &&
                                     (x.Currency.Equals(CurrencyRateConstants.CurrencyEUR, StringComparison.OrdinalIgnoreCase) ||
                                      x.Currency.Equals(CurrencyRateConstants.CurrencyUSD, StringComparison.OrdinalIgnoreCase)))
                              .Select(x => new CurrencyRateInsertEntity {
             Date            = date,
             BaseCurrency    = x.BaseCurrency,
             ToCurrency      = x.Currency,
             SaleRateNBU     = x.SaleRateNB,
             PurchaseRateNBU = x.PurchaseRateNB,
             SaleRatePB      = (decimal)x.SaleRate,
             PurchaseRatePB  = (decimal)x.PurchaseRate
         })
                              .ToList();
         _logger.LogDebug($"Trying to insert {entityToInsert.Count} entities");
         await _currencyRateRepository.AddCurrencyRates(entityToInsert);
     }
 }