Exemple #1
0
        private ClientUser RegisterNewUser(string userName, string password)
        {
            if (_storageHandler.UserNameExists(userName))
            {
                throw new UserAlreadyExistException(
                          $"Account with user name '{userName}' already exists. Please enter another user name and try again.");
            }

            int userId = _storageHandler.GetNextUserId();

            ClientUser newUser = new ClientUser(userId, userName);

            _registeredUsers.Add(newUser);

            _storageHandler.AddToRegisteredUsers(newUser, password);

            return(newUser);
        }