public ApplicationCommandProcessor( IApplicationCommandingContext context, ILogger <ApplicationCommandProcessor <TApplicationCommand> > logger) { _context = context; _logger = logger; }
public void OnApplicationCommand(IApplicationCommandingContext context, CreateApplicationCommand command) { _logger.LogInformation($"The application command: {nameof(command)}[Payload: {command.Payload}] handled."); var create = new CreateDomainCommand(command.Payload); _domainCommandPublisher.Publish(create); }
public void OnApplicationCommand( IApplicationCommandingContext context, ChangeAccountNameApplicationCommand appCommand) { var domainCommand = new ChangeAccountNameDomainCommand(appCommand.AccountId, appCommand.AccountName); context.PublishDomainCommand(domainCommand); }
public void OnApplicationCommand(IApplicationCommandingContext context, StartWithdrawApplicationCommand appCommand) { var transactionId = SnowflakeId.Default().NextId(); var command = new StartWithdrawTransactionDomainCommand(transactionId, appCommand.AccountId, appCommand.AccountName, appCommand.Amount, appCommand.Bank); context.PublishDomainCommand(command); }
public async Task OnApplicationCommandAsync( IApplicationCommandingContext context, CreateApplicationCommand command, CancellationToken token = default) { _logger.LogInformation($"The application command: {nameof(command)}[Payload: {command.Payload}] handled."); var create = new CreateDomainCommand(command.Payload); _domainCommandPublisher.Publish(create); await Task.CompletedTask; }
public void OnApplicationCommand(IApplicationCommandingContext context, StartTransferApplicationCommand command) { var transactionId = SnowflakeId.Default().NextId(); var source = command.SourceAccount; var sink = command.SinkAccount; var domainCommand = new StartTransferTransactionDomainCommand( transactionId, new TransferAccount(source.Id, source.Name, source.Bank, TransferAccountType.Source), new TransferAccount(sink.Id, sink.Name, sink.Bank, TransferAccountType.Sink), command.Amount); context.PublishDomainCommand(domainCommand); }
public void OnApplicationCommand(IApplicationCommandingContext context, StartDepositApplicationCommand appCommand) { var transactionId = SnowflakeId.Default().NextId(); var domainCommand = new StartDepositTransactionDomainCommand(transactionId, appCommand.AccountId, appCommand.AccountName, appCommand.Amount, appCommand.Bank) { ApplicationCommandId = appCommand.Id, ApplicationCommandType = appCommand.GetType().FullName, ApplicationCommandReplyScheme = appCommand.ReplyScheme }; context.PublishDomainCommand(domainCommand); }
public async Task OnApplicationCommandAsync( IApplicationCommandingContext context, OpenBankAccountApplicationCommand appCommand, CancellationToken token = default) { var hadAccountName = await _accountRepository.HadAccountNameAsync(appCommand.AccountName).ConfigureAwait(false); if (hadAccountName) { throw new BankAccountDomainException("账户名已经存在。"); } var domainCommand = new OpenAccountDomainCommand( appCommand.AccountId, appCommand.AccountName, appCommand.Bank, appCommand.InitialBalance); context.PublishDomainCommand(domainCommand); }