public async Task <CurrencyValueDto> ConvertCurrency(CurrencyConverterParams currencyConverterParams) { _logger.LogInformation("GET - convert parameters"); var fromCurrency = await _APIConsumer.GetExchangeRatesForCurrency(currencyConverterParams.CodeFrom); var toCurrency = await _APIConsumer.GetExchangeRatesForCurrency(currencyConverterParams.CodeTo); var convertedValue = Convert(fromCurrency.Rates[0].Mid, toCurrency.Rates[0].Mid, currencyConverterParams.Value); return(new CurrencyValueDto(toCurrency.Currency, toCurrency.Code, toCurrency.Rates[0].Mid, convertedValue)); }
public async Task <CurrencyExternal> GetCurrency(string code) { _logger.LogInformation("GET - currency details"); if (await _dBContext.Currencies.FirstOrDefaultAsync(x => x.Code.Equals(code.ToUpper())) == null) { throw new Exception($"Currency with code {code} does not exists in database!"); } return(await _APIConsumer.GetExchangeRatesForCurrency(code)); }