示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
 public InfoResult(CurrencyDto[] currencies, CurrentRatesInfoDto ratesInfo)
 {
     Currencies = currencies;
     RatesInfo  = ratesInfo;
 }