public bool ExternalConnection() { try { var rate = _cryptoComparer.GetLastestRate("BRL"); if (rate > 0) { return(true); } else { return(false); } } catch (Exception ex) { _logger.LogError($"Error: {ex.Message}"); return(false); } }
public bool UpdateRate(Currency currency) { try { var latestRate = _cryptoComparer.GetLastestRate(currency.name); currency.rate = latestRate; currency.lastUpdate = DateTime.Now; if (_repo.Update <Currency>(currency)) { _cache.SetAsync(currency.name, latestRate.ToString()); } else { _logger.LogError($"Database update failed to {currency.name}"); throw new Exception($"Database update failed"); } return(true); } catch (Exception ex) { _logger.LogError($"Called UpdateRate failed with {ex.Message}"); throw new Exception($"Update rate failed"); } }