private bool UsernameInputIsValid()
        {
            if (FieldIsEmpty(screen.UsernameTextBox, "Username"))
            {
                screen.UsernameValidatorLabel.Text = "Enter valid username";
                return(false);
            }
            if (FieldIsEmpty(screen.PasswordTextBox, "Password"))
            {
                return(false);
            }

            string username = screen.UsernameTextBox.Text.Trim();

            bool userExists = UserFileUtil.UsernameExists(username);

            if (!userExists)
            {
                screen.UsernameValidatorLabel.Text = "Couldn't find your username";
                return(false);
            }

            screen.UsernameValidatorLabel.Text = "";
            return(true);
        }
Beispiel #2
0
        private bool UsernameInputIsValid()
        {
            string username = screen.RUsernameTextBox.Text.Trim();

            if (username.Length == 0)
            {
                screen.RegisterUserNameValidatorLabel.Text = "Enter username";
                return(false);
            }

            if (username.Where(Char.IsLetter).Count() == 0)
            {
                screen.RegisterUserNameValidatorLabel.Text = "Wrong username format";
                return(false);
            }

            if (username.Equals("Username"))
            {
                screen.RegisterUserNameValidatorLabel.Text = "Enter valid username";
                return(false);
            }

            bool userExists = UserFileUtil.UsernameExists(username);

            if (userExists)
            {
                screen.RegisterUserNameValidatorLabel.Text = "This username is already registered";
                return(false);
            }

            screen.RegisterUserNameValidatorLabel.Text = "";
            return(true);
        }