Exemplo n.º 1
0
        private void Login_Click(object sender, EventArgs e)
        {
            if (!InputValidator.isNotEmpty(this.usernameInput.Text) ||
                !InputValidator.isNotEmpty(this.passwordInput.Password))
            {
                toastDisplay = GlobalToastPrompt.CreateToastPrompt(
                    "Oops!",
                    "Please check that you have entered all required fields.",
                    3000);
                toastDisplay.Show();
                return;
            }


            App.MetrocamService.AuthenticateCompleted += new MobileClientLibrary.RequestCompletedEventHandler(MetrocamService_AuthenticateCompleted_Login);
            GlobalLoading.Instance.IsLoading           = true;

            // Atach timer event handler for tick
            this.timer.Tick += new EventHandler(timer_Tick);
            // Set one second as each tick
            this.timer.Interval = new TimeSpan(0, 0, 1);
            // Start timer
            this.timer.Start();

            App.MetrocamService.Authenticate(this.usernameInput.Text, this.passwordInput.Password);
        }
        // Begin validation sequence
        private string CheckAllInputs()
        {
            // Checks if any of the required fields are empty
            if (!InputValidator.isNotEmpty(this.UsernameInput.Text) ||
                !InputValidator.isNotEmpty(this.FullnameInput.Text) ||
                !InputValidator.isNotEmpty(this.PasswordInput.Password) ||
                !InputValidator.isNotEmpty(this.ConfirmPasswordInput.Password) ||
                !InputValidator.isNotEmpty(this.EmailInput.Text))
            {
                return("Please check that you have entered all required fields.");
            }

            // Checks if username is valid
            if (!InputValidator.isValidUsername(this.UsernameInput.Text))
            {
                return("Please check that your username is valid.");
            }

            // Checks if both passwords are similar
            if (!InputValidator.isPasswordSame(this.PasswordInput.Password, this.ConfirmPasswordInput.Password))
            {
                return("Please check that both passwords match.");
            }

            // Checks if password is valid
            if (!InputValidator.isStrongPassword(this.PasswordInput.Password))
            {
                return("Please check that your password is valid.");
            }

            // Checks if email is valid
            if (!InputValidator.isValidEmail(this.EmailInput.Text))
            {
                return("Please check that your email is valid.");
            }

            // Input validation passed
            return("Valid");
        }