public async Task CompareExchangeRates() { var todayRatesResponseMessage = await _exchangeRateClient.GetTodayRates(); if (todayRatesResponseMessage.StatusCode == System.Net.HttpStatusCode.OK) { var content = todayRatesResponseMessage.Content; var nbsExchangeRates = await content.ReadAsAsync <NbsExchangeRates>(); var oneUsdToRsdRate = nbsExchangeRates.Rates.First(rate => rate.Code.Equals("USD")); //TODO; FirstOrDefault and add validation var oneEurToRsdRate = nbsExchangeRates.Rates.First(rate => rate.Code.Equals("EUR")); var oneGbpToRsdRate = nbsExchangeRates.Rates.First(rate => rate.Code.Equals("GBP")); var oneUsdToEurRate = oneUsdToRsdRate.Exchange_middle / oneEurToRsdRate.Exchange_middle; var oneUsdToGbpRate = oneUsdToRsdRate.Exchange_middle / oneGbpToRsdRate.Exchange_middle; var openExchangeRate = _exchangeRateRepository.GetAll(); //TODO Allow get by day and currency, not all var oneUsdToEurOpenExchangeRate = openExchangeRate.First(rate => rate.RateCurrency.Equals("EUR")); //TODO Need to make sure its today's var oneUsdToGbpOpenExchangeRate = openExchangeRate.First(rate => rate.RateCurrency.Equals("GBP")); Console.WriteLine($"NBS(middle) - 1 USD = {oneUsdToEurRate} EUR"); Console.WriteLine($"NBS(middle) - 1 USD = {oneUsdToGbpRate} GBP"); Console.WriteLine($"Open - 1 USD = {oneUsdToEurOpenExchangeRate.Rate} EUR"); Console.WriteLine($"Open - 1 USD = {oneUsdToGbpOpenExchangeRate.Rate} GBP"); } }
public IEnumerable <ExchangeRate> GetAllExchangeRates() { return(_exchangeRateRepository.GetAll()); }
// Manager in charge of get all ExchangeRate. public async Task <IEnumerable <ExchangeRateModel> > GetAllExchangeRate() { var exchangeRateList = await _exchangeRateRepository.GetAll(); return(_mapper.Map <IEnumerable <ExchangeRate>, IEnumerable <ExchangeRateModel> >(exchangeRateList)); }