public async Task ProcessP2PTransferDetectedEventAsync( string contextId, string transactionHash, string senderCustomerId, string receiverCustomerId, Money18 amount, DateTime timestamp) { var transferContext = await _transfersRepository.GetAsync(contextId); if (transferContext == null) { _log.Error(message: ContextNotFoundMsg, context: new { requestId = contextId, transactionHash, senderCustomerId, receiverCustomerId }); throw new InvalidOperationException(ContextNotFoundMsg); } await _p2PTransferEventPublisher.PublishAsync(new P2PTransferEvent { Amount = amount, Timestamp = timestamp, SenderCustomerId = senderCustomerId, ReceiverCustomerId = receiverCustomerId, AssetSymbol = transferContext.AssetSymbol, TransactionId = transferContext.OperationId, ExternalOperationId = transferContext.ExternalOperationId }); var senderCurrentBalance = await GetCustomerCurrentBalance(senderCustomerId); var receiverCurrentBalance = await GetCustomerCurrentBalance(receiverCustomerId); var senderCustomerEmail = await GetCustomerEmail(senderCustomerId); var receiverCustomerEmail = await GetCustomerEmail(receiverCustomerId); var senderEmailNotificationTask = _emailsPublisher.SendP2PSucceededForSenderAsync(senderCustomerId, contextId, amount, timestamp, senderCurrentBalance, receiverCustomerEmail); var receiverEmailNotificationTask = _emailsPublisher.SendP2PSucceededForReceiverAsync(receiverCustomerId, contextId, amount, timestamp, receiverCurrentBalance, senderCustomerEmail); var senderPushNotificationTask = _pushNotificationsPublisher.PublishP2PSucceededForSenderAsync(senderCustomerId); var receiverPushNotificationTask = _pushNotificationsPublisher.PublishP2PSucceededForReceiverAsync(receiverCustomerId, amount, senderCustomerEmail); await Task.WhenAll( senderEmailNotificationTask, receiverEmailNotificationTask, senderPushNotificationTask, receiverPushNotificationTask); await _transfersRepository.DeleteAsync(contextId); }