private async Task ProcessMessageAsync(List <TradeLogItem> arg) { try { await _tradesRepository.AddDataItemsAsync(arg); var walletsToUpdate = arg .Where(i => i.UserId != i.WalletId) .Select(i => i.WalletId) .Distinct() .ToList(); foreach (var walletId in walletsToUpdate) { var wallet = await _clientAccountClient.GetWalletAsync(walletId); if (wallet == null) { continue; } await _walletsRepository.AddDataItemAsync( new Wallet { Id = wallet.Id, Type = wallet.Type, Name = wallet.Name, Owner = wallet.Owner, UserId = wallet.ClientId, }); } } catch (Exception exc) { _log.WriteError("TradelogSubscriber.ProcessMessageAsync", arg, exc); } }