Ejemplo n.º 1
0
        public void Execute()
        {
            string password             = _registerInformations.Password;
            string passwordConfirmation = _registerInformations.PasswordConfirmation;

            if (password != passwordConfirmation)
            {
                throw new Exception("Password and password confirmation have to be equal.");
            }

            var registerRequest = new RegisterRequest {
                Password = _hashService.GetHash(password)
            };
            RegisterResponse registerResponse = _serverConnection.SendRegisterRequest(registerRequest);

            if (!registerResponse.WasSuccessfull)
            {
                throw new Exception("Cannot create new account.");
            }

            _eventAggregator.Publish(new Registered(registerResponse.AccountNumber));
        }