コード例 #1
0
        public void Handle(ConfirmUserCommand command)
        {
            UserRegistrationSaga     saga = new UserRegistrationSaga(_commandBus, _passwordHasher);
            UserRegistrationSagaData data = _sagaRepository.Get <UserRegistrationSagaData>(command.ConfirmationId);

            if (data == null)
            {
                throw new InvalidOperationException();
            }
            saga.RaiseEvent(data, saga.ConfirmUserCommand, command);
            _sagaRepository.Save(command.ConfirmationId, data);
        }
コード例 #2
0
        public void Handle(RegisterUserCommand command)
        {
            if (_query.Query <AccountReadModel, string>(command.LoginName) != null)
            {
                throw new LoginNameAlreadyUsedException(command.LoginName);
            }

            if (_sagaRepository.Get <UserRegistrationSagaData>(command.LoginName) != null)
            {
                throw new LoginNameAlreadyUsedException(command.LoginName);
            }

            UserRegistrationSaga     saga = new UserRegistrationSaga(_commandBus, _passwordHasher);
            UserRegistrationSagaData data = new UserRegistrationSagaData {
                Id = command.Id
            };

            saga.RaiseEvent(data, saga.RegisterUserCommand, command);
            _sagaRepository.Save(data.Id, data);
        }