public async Task Process <TCommand>(ICommandWrapper <TCommand> commandWrapper) where TCommand : ICommand { var commandHandler = _commandHandlerFactory.Resolve <TCommand>(); IReadOnlyCollection <IEvent> events; try { events = await commandHandler.Handle(commandWrapper.Command); } catch (Exception ex) { if (commandWrapper.IsLinkToJob) { await _jobHandler.Fail(commandWrapper, ex); } return; } if (events.Any()) { await _eventDispatcher.Send(commandWrapper, events); } else { await _jobHandler.Done(commandWrapper); } }
public async Task Process <TEvent>(IEventWrapper <TEvent> eventWrapper) where TEvent : IEvent { var eventHandler = _eventHandlerFactory.Resolve <TEvent>(); IReadOnlyCollection <IAction> actions; try { actions = await eventHandler.Handle(eventWrapper.Event); } catch (Exception ex) { if (eventWrapper.IsLinkToJob) { await _jobHandler.Fail(eventWrapper, ex); } return; } if (actions.Any()) { await _actionDispatcher.Send(eventWrapper, actions); } else { await _jobHandler.Done(eventWrapper); } }