예제 #1
0
        protected override async Task <ExecuteCommandResult <IEvent> > ExecuteCommand(IEvent[] given, ICommand cmd)
        {
            var repository = new BDDAggregateRepository();

            repository.Preload(cmd.Id, given);
            var svc = new OrganizationInteractor(repository);
            await svc.Execute(cmd).ConfigureAwait(false);

            var publishedEvents = svc.GetPublishedEvents();
            var arr             = (repository.Appended != null) ? repository.Appended.Cast <IEvent>().ToArray() : null;

            return(new ExecuteCommandResult <IEvent> {
                ProducedEvents = arr ?? new IEvent[0], PublishedEvents = publishedEvents.Cast <IEvent>().ToArray()
            });
        }
예제 #2
0
        protected override async Task <ExecuteCommandResult <IEvent> > ExecuteCommand(IEvent[] given, ICommand cmd)
        {
            var repository = new BDDAggregateRepository();

            repository.Preload(cmd.Id, given);
            var svc = new PersonAggregateInteractor(repository); //inject interactor specific dependencies here
            await svc.Execute(cmd);

            var publishedEvents = svc.GetPublishedEvents();
            var arr             = (repository.Appended != null) ? repository.Appended.Cast <IEvent>().ToArray() : null;
            var res             = new ExecuteCommandResult <IEvent> {
                ProducedEvents = arr ?? new IEvent[0], PublishedEvents = publishedEvents.Cast <IEvent>().ToArray()
            };

            return(res);
        }