public async Task <CommandHandlingResult> Handle(ProcessCashInCommand command, IEventPublisher eventPublisher) { var id = command.CommandId; var asset = command.Asset; var amount = command.Amount; var transaction = command.Transaction; ChaosKitty.Meow(); var responseModel = await _matchingEngineClient.CashInOutAsync(id, transaction.ClientId, asset.Id, amount.TruncateDecimalPlaces(asset.Accuracy)); if (responseModel.Status != MeStatusCodes.Ok && responseModel.Status != MeStatusCodes.AlreadyProcessed && responseModel.Status != MeStatusCodes.Duplicate) { _log.WriteInfo(nameof(ProcessCashInCommand), command, responseModel.ToJson()); throw new ProcessingException(responseModel.ToJson()); } ChaosKitty.Meow(); eventPublisher.PublishEvent(new TransactionProcessedEvent { ClientId = command.Transaction.ClientId, Asset = command.Asset, Amount = command.Amount }); return(CommandHandlingResult.Ok()); }
private void Handle(BitcoinCashInRegisteredEvent evt, ICommandSender sender) { var cmd = new ProcessCashInCommand { Transaction = evt.Transaction, Asset = evt.Asset, Amount = evt.Amount, CommandId = evt.CommandId }; sender.SendCommand(cmd, "cashin"); }