Ejemplo n.º 1
0
        public ISaga Continue(Guid id)
        {
            var saga = _librarian.Get(id);

            saga.Continue();
            return(saga);
        }
Ejemplo n.º 2
0
        public SagaConclusion Conclude(Guid sagaId)
        {
            var saga       = _sagaLibrarian.Get(sagaId);
            var conclusion = _sagaNarrator.Conclude(saga);

            return(conclusion);
        }
Ejemplo n.º 3
0
        public IEnumerable <CommandResult> HandleForSaga(Guid sagaId, CommandDescriptor[] commandDescriptors)
        {
            var results = new List <CommandResult>();
            var saga    = _sagaLibrarian.Get(sagaId);

            // Todo : IMPORTANT : We need to treat this as a unit of work with rollbacks if one or more commands fail and some succeed!!!!!!!!!!!
            foreach (var commandDescriptor in commandDescriptors)
            {
                ICommand commandInstance = null;
                try
                {
                    commandInstance = GetCommandFromDescriptor(commandDescriptor);
                    results.Add(_commandCoordinator.Handle(saga, commandInstance));
                }
                catch (Exception ex)
                {
                    var commandResult = CommandResult.ForCommand(commandInstance);
                    commandResult.Exception = ex;
                    return(new[] { commandResult });
                }
            }

            return(results.ToArray());
        }