private CurrentRatesInfoDto LoadRates(CurrencyDto[] currencies) { var rates = new List <CurrencyRateInfoDto>(); foreach (CurrencyDto currency in currencies) { if (currency.IsoCode == DefaultCurrencyIsoCode) { continue; } RateInfo rate = _rates.GetRateOrDefault(currency.IsoCode, DefaultCurrencyIsoCode); if (rate == null) { continue; } var currencyRateInfo = new CurrencyRateInfoDto(currency.IsoCode, rate.Rate, rate.Date); rates.Add(currencyRateInfo); } var ratesInfo = new CurrentRatesInfoDto(rates, DefaultCurrencyIsoCode); return(ratesInfo); }
public async Task <InfoResult> Handle(InfoQuery request, CancellationToken cancellationToken) { CurrencyDto[] currencies = await _context.Currencies.ProjectAsync <Currency, CurrencyDto>(_mapper.ConfigurationProvider, cancellationToken); CurrentRatesInfoDto ratesInfo = LoadRates(currencies); return(new InfoResult(currencies, ratesInfo)); }
public InfoResult(CurrencyDto[] currencies, CurrentRatesInfoDto ratesInfo) { Currencies = currencies; RatesInfo = ratesInfo; }