private async Task <IReadOnlyCollection <ICoinInfo> > GetCoinInfoAsync(ICoinClient client) { this.Logger.LogInformation($"Updating {client.GetType().Name} CoinInfo"); try { return(await client.GetCoinInfoAsync()); } catch (Exception exception) { this.Logger.LogError(new EventId(exception.HResult), exception: exception, $"Failed to update {client.GetType().Name} CoinInfo: {exception.Message}"); return(Array.Empty <ICoinInfo>()); } }
private Task UpdateGlobalInfo() { ICoinClient client = this._coinClients.First(); //this._lock.EnterWriteLock(); try { this._globalInfo = client.GetGlobalInfo().Result; return(Task.CompletedTask); } finally { //this._lock.ExitWriteLock(); } }
private Task UpdateCoins() { ICoinClient client = this._coinClients.First(); //this._lock.EnterWriteLock(); try { List <ICoinInfo> coinInfos = client.GetCoinInfo().Result.ToList(); List <Currency> currencies = new List <Currency>(); currencies.AddRange(new[] { new Currency { Symbol = "EUR", Name = "Euro" }, new Currency { Symbol = "USD", Name = "United States dollar" } }); currencies.AddRange(coinInfos.Select(cryptoInfo => { Currency currency = new Currency { Symbol = cryptoInfo.Symbol, Name = cryptoInfo.Name, ImageUrl = cryptoInfo.ImageUrl }; currency.AddDetails(cryptoInfo); return(currency); })); this._coinInfoCollection = new ReadOnlyCollection <Currency>(currencies); return(Task.CompletedTask); } finally { //this._lock.ExitWriteLock(); } }
public StoreCryptoController(ICNWRepository repository, ILogger <StoreCryptoController> logger, ICoinClient cryptoPriceService) { _repositiry = repository; _logger = logger; _cryptoPriceService = cryptoPriceService; }