public async Task <CommandHandlingResult> Handle(SaveEthInHistoryCommand command, IEventPublisher eventPublisher) { var sw = new Stopwatch(); sw.Start(); try { var cashinId = command.CashinOperationId.ToString("N"); var clientId = command.ClientId; var hash = command.TransactionHash; var amount = command.Amount; var clientAddress = command.ClientAddress; await _cashOperationsRepositoryClient.RegisterAsync(new CashInOutOperation { Id = cashinId, ClientId = clientId.ToString(), AssetId = command.AssetId, Amount = (double)amount, BlockChainHash = hash, DateTime = DateTime.UtcNow, AddressTo = clientAddress, State = TransactionStates.SettledOnchain }); ChaosKitty.Meow(); var clientAcc = await _clientAccountClient.GetByIdAsync(clientId.ToString()); var clientEmail = await _personalDataService.GetEmailAsync(clientId.ToString()); await _srvEmailsFacade.SendNoRefundDepositDoneMail(clientAcc.PartnerId, clientEmail, amount, command.AssetId); await _paymentTransactionsRepository.SetStatus(hash, PaymentStatus.NotifyProcessed); ChaosKitty.Meow(); eventPublisher.PublishEvent(new EthCashinSavedInHistoryEvent() { TransactionHash = hash }); return(CommandHandlingResult.Ok()); } catch (Exception e) { _log.Error(nameof(SaveEthInHistoryCommand), e, context: command); throw; } finally { sw.Stop(); _log.Info("Command execution time", context: new { TxHandler = new { Handler = nameof(EthereumCoreCommandHandler), Command = nameof(SaveEthInHistoryCommand), Time = sw.ElapsedMilliseconds } }); } }
public async Task Process(HashEvent ev) { var tx = await _bitcoinTransactionRepository.FindByTransactionIdAsync(ev.Id); if (tx == null) { return; } string hash = ev.Hash; switch (tx.CommandType) { case BitCoinCommands.CashOut: var cashOutContext = await _transactionService.GetTransactionContext <CashOutContextData>(tx.TransactionId); var clientAcc = await _сlientAccountClient.GetByIdAsync(cashOutContext.ClientId); var clientEmail = await _personalDataService.GetEmailAsync(cashOutContext.ClientId); await _cashOperationsRepositoryClient.UpdateBlockchainHashAsync(cashOutContext.ClientId, cashOutContext.CashOperationId, hash); await _srvEmailsFacade.SendNoRefundOCashOutMail(clientAcc.PartnerId, clientEmail, cashOutContext.Amount, cashOutContext.AssetId, hash); break; } }
public async Task <string> GetEmail(string clientId) { return(await _personalDataService.GetEmailAsync(clientId)); }