private async Task Handle(ClientRetrievedEvent evt, ICommandSender sender) { var aggregate = await _cashinRepository.GetAsync(evt.OperationId); var transitionResult = aggregate.OnClientRetrieved(clientId: evt.ClientId); if (transitionResult.ShouldSaveAggregate()) { await _cashinRepository.SaveAsync(aggregate); } if (transitionResult.ShouldSendCommands()) { sender.SendCommand ( new ValidateOperationCommand { OperationId = aggregate.OperationId, Type = OperationType.Deposit, UserId = aggregate.ClientId.Value, BlockchainType = aggregate.BlockchainType, BlockchainAssetId = aggregate.BlockchainAssetId, FromAddress = aggregate.DepositWalletAddress, ToAddress = aggregate.HotWalletAddress, Amount = aggregate.BalanceAmount.Value }, BlockchainRiskControlBoundedContext.Name ); _chaosKitty.Meow(evt.OperationId); } }
public async Task Handle(EnrolledBalanceSetEvent evt) { var aggregate = await _cashinRepository.GetAsync(evt.OperationId); if (!aggregate.IsDustCashin.HasValue) { throw new InvalidOperationException("IsDustCashin should be not null here"); } if (aggregate.IsDustCashin.Value) { await _deduplicationRepository.TryRemoveAsync(evt.OperationId); } _chaosKitty.Meow(evt.OperationId); }