public Task <List <WalletWithBalance> > GetListOfMtGoxWalletsWithBalances() { using (var context = new MtGoxAddressesContext()) { return(context.WalletAddresses .Select(address => new WalletWithBalance { Address = address.Hash160Address, LastKnownBalance = address.LastKnownBalance, }) .ToListAsync()); } }
private async Task UpdateMtGoxDbData() { using (var context = new MtGoxAddressesContext()) { var addresses = context.WalletAddresses; var addressesCount = addresses.Count(); var idx = 1; foreach (var address in addresses) { _logger.LogDebug($"{idx++}/{addressesCount} - updating addresses info {address.Hash160Address}"); var dateNow = DateTime.Now; if (ShouldUpdateAddressInfo(address, dateNow)) { try { var addressInfo = await _blockchainApiClient.GetAddressBaseInformation(address.Hash160Address); address.TotalBalance = addressInfo.TotalReceived; address.LastKnownBalance = addressInfo.LastBalance; address.LastOperationDateTime = addressInfo.LastTransaction; address.LastCheckedDateTime = dateNow; } catch (Exception e) { _logger.Log(LogLevel.Error, e, $"Error occured during UpdateMtGoxDbData"); throw; } } context.SaveChanges(); } } }