public async Task HandleAsync(ListTransactionsCommand command, CancellationToken cancellationToken = default(CancellationToken)) { // get data var data = await bankingService.GetTransactionsAsync(command.AccountId, cancellationToken); // sent event to print await eventDelegator.SendAsync(new ShowListTransactionEvent(data), cancellationToken); }
public async Task ShouldNotThrowIfNoEventHandlerIsRegisteredInContainer() { var container = new Container(); var adapter = new SimpleInjectorContainerAdapter(container); var eventHandlerResolver = new ContainerEventHandlerResolver(adapter); var delegator = new EventDelegator(eventHandlerResolver); await delegator.SendAsync(new TestEvent1()); }
public async Task SaveAsync(Product product, CancellationToken cancellationToken = default(CancellationToken)) { // Get copy. IReadOnlyCollection <IDomainEvent> uncommittedDomainEvents = product.GetUncommittedDomainEvents(); // Do actual save. await _inner.SaveAsync(product, cancellationToken); // Send each domain events to handlers. List <Task> publishDomainEventTasks = uncommittedDomainEvents.Select(e => _eventDelegator.SendAsync(e, cancellationToken)).ToList(); // Complete when all events have completed. await Task.WhenAll(publishDomainEventTasks); }
public async Task HandleAsync(CheckBalanceCommand command, CancellationToken cancellationToken = default(CancellationToken)) { var debitAccountInfo = await this.bankingService.GetBankingAccountAsync(command.DebitAccountId, cancellationToken); await eventDelegator.SendAsync(new ShowAccountDetailEvent(debitAccountInfo), cancellationToken); }
public async Task Run() { do { try { await _eventDelegator.SendAsync(new ShowHomeScreenEvent()); var keyCode = Console.ReadKey(); if (int.TryParse(keyCode.KeyChar.ToString(), out int actionNumber)) { var action = (ActionEnum)Convert.ToInt16(actionNumber); switch (action) { case ActionEnum.CreateAccount: await _eventDelegator.SendAsync(new ShowCreateAccountScreenEvent()); break; case ActionEnum.Login: await _eventDelegator.SendAsync(new ShowLoginScreenEvent()); break; case ActionEnum.Logout: var ApplicationContext = _serviceProvider.GetService(typeof(ApplicationContext)) as ApplicationContext; await _commandDelegator.SendAsync(new LogoutCommand(ApplicationContext.UserInfo.AccessToken)); break; case ActionEnum.CreateDeposit: await _eventDelegator.SendAsync(new ShowRecordDepositScreenEvent()); break; case ActionEnum.CreateWithDraw: await _eventDelegator.SendAsync(new ShowRecordWithdrawScreenEvent()); break; case ActionEnum.CheckBalance: await _commandDelegator.SendAsync(new CheckBalanceCommand(_applicationContext.UserInfo.DebitAccountId)); break; case ActionEnum.ListTransactions: await _commandDelegator.SendAsync(new ListTransactionsCommand(_applicationContext.UserInfo.DebitAccountId)); break; case ActionEnum.Close: return; default: break; } } } catch (Exception ex) { _logger.LogCritical(ex.Message); Console.ReadKey(); } }while (true); }