public async Task <BalanceUpdateDetails> GetDetailsByIdAsync(string brokerId, long id) { var balanceUpdate = await _balanceUpdateRepository.GetByIdAsync(brokerId, id); if (balanceUpdate == null) { return(null); } BalanceUpdateDetails result = null; switch (balanceUpdate.EventType) { case BalanceUpdateEventType.CashIn: var cashIn = await _cashInRepository.GetByBalanceUpdateIdAsync(brokerId, balanceUpdate.MessageId); if (cashIn == null) { return(null); } result = new BalanceUpdateDetails { Asset = cashIn.AssetId, Volume = decimal.Parse(cashIn.Volume), Type = BalanceUpdateType.CashIn, Description = cashIn.Description }; break; case BalanceUpdateEventType.CashOut: var cashOut = await _cashOutRepository.GetByBalanceUpdateIdAsync(brokerId, balanceUpdate.MessageId); if (cashOut == null) { return(null); } result = new BalanceUpdateDetails { Asset = cashOut.AssetId, Volume = decimal.Parse(cashOut.Volume), Type = BalanceUpdateType.CashOut, Description = cashOut.Description }; break; case BalanceUpdateEventType.CashTransfer: var cashTransfer = await _cashTransferRepository.GetByBalanceUpdateIdAsync(brokerId, balanceUpdate.MessageId); if (cashTransfer == null) { return(null); } result = new BalanceUpdateDetails { Asset = cashTransfer.AssetId, Volume = decimal.Parse(cashTransfer.Volume), Type = BalanceUpdateType.CashTransfer, FromWalletId = cashTransfer.FromWalletId, ToWalletId = cashTransfer.ToWalletId, Description = cashTransfer.Description }; break; default: _logger.LogWarning("Unsupported type of balance update. {@BalanceUpdateEventType}", balanceUpdate.EventType); break; } return(result); }
public Task <CashOut> GetByIdAsync(string brokerId, long id) { return(_cashOutRepository.GetByBalanceUpdateIdAsync(brokerId, id)); }