public async Task <IActionResult> GetLatestRates() { ExchangeRatesView ratesView = null; int count = ratesService.GetAPIsCallsCount(); if (count >= 999) { return(Ok(null)); } ratesView = await ratesService.GetLatestCurrencyRates(); if (ratesView.Rates == null) { string apiKey = ratesService.GetAPIKeyForOpenExchange(); ratesView = await ratesHttpService.GetRatesAsync(apiKey); if (ratesView.Rates != null) { await ratesService.SaveCurrencyRatesAsync(ratesView.Rates, DateTime.Now); } } return(Ok(ratesView)); }