public async Task <IActionResult> GetCalculatedExchangeForCurrencies(int amount, string fromCurrency, string toCurrency) { var uriString = _apiConnections.UriString; string dataFromCurrency; string dataToCurrency; try { dataFromCurrency = await _exchange.GetExchangeRatesData(uriString, _apiConnections.RequestUriToSingleRate(fromCurrency)); dataToCurrency = await _exchange.GetExchangeRatesData(uriString, _apiConnections.RequestUriToSingleRate(toCurrency)); } catch (StatusCodeException e) { var codeNumber = e.CodeNumber; return(StatusCode(codeNumber, StatusCodeResponses.GetResponseMessage(codeNumber))); } var currencyFrom = _currencyDao.GetCurrency(fromCurrency.ToUpper(), _context, _codesForExchangeRates); var currencyTo = _currencyDao.GetCurrency(toCurrency.ToUpper(), _context, _codesForExchangeRates); var conversions = _exchange.GetConversionsDetails(dataFromCurrency, dataToCurrency, amount, currencyFrom, currencyTo); await _conversionDao.AddConversions(conversions, _context); var actualConversion = $"{amount}{fromCurrency.ToUpper()}:{conversions.Result}{toCurrency.ToUpper()}"; var currency = JsonConvert.SerializeObject(actualConversion); return(Ok(currency)); }