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() }); }
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); }