Пример #1
0
        public async Task Send <TCommand, TEvent>(ICommandWrapper <TCommand> parentCommand,
                                                  IReadOnlyCollection <TEvent> events) where TCommand : ICommand where TEvent : IEvent
        {
            var wrappedEvents = events
                                .Select(e => e.Wrap(parentCommand))
                                .ToArray();

            if (parentCommand.IsLinkToJob)
            {
                await _jobHandler.Associate(parentCommand, wrappedEvents);
            }
            await _eventStore.Save(wrappedEvents);

            await ProcessEvents(wrappedEvents);
        }
Пример #2
0
        public async Task Send(IEventWrapper eventParent, IReadOnlyCollection <IAction> actions)
        {
            var wrappedActions = actions
                                 .Select(c => c.Wrap())
                                 .ToArray();

            if (eventParent.IsLinkToJob)
            {
                await _jobHandler.Associate(eventParent, wrappedActions);
            }
            await _commandStore.Save(wrappedActions);

            foreach (var wrappedAction in wrappedActions)
            {
                await _commandQueue.Send(wrappedAction);
            }
        }