Exemple #1
0
        public async Task ProcessAsync <TCommand>(TCommand command) where TCommand : CommandBase
        {
            foreach (var commandHandler in _commandHandlers.Where(e => e.GetCommandType() == command.GetType()))
            {
                var aggregate = await commandHandler.UpdatedAggregateAsync(command);

                if (aggregate != null)
                {
                    var newEvents = aggregate.UncommittedEvents;
                    await _aggregateRepo.AddOrUpdateAsync(aggregate);

                    await _eventDispatcher.DispatchAsync(newEvents);
                }
            }
        }