Example #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string username = usernameBox.Text.Trim();
            string password = passwordBox.Password.Trim();

            errorBlock.Visibility = Visibility.Hidden;
            if (username.Length > 0 && password.Length > 0)
            {
                this.Cursor = Cursors.Wait;
                Button button = (Button)sender;
                button.Cursor = Cursors.Wait;

                EmployeeLoginResponse response = await client.EmployeeLoginAsync(username, password);

                this.Cursor   = Cursors.Arrow;
                button.Cursor = Cursors.Hand;
                if (response.Body.EmployeeLoginResult != 1)
                {
                    errorBlock.Visibility = Visibility.Visible;
                    errorBlock.Text       = "Invalid login attempt";
                }
                else
                {
                    Application.Current.Resources["username"] = username;
                    Application.Current.Resources["password"] = password;
                    SubmitRequest submitRequest = new SubmitRequest();
                    submitRequest.Show();
                    this.Close();
                }
            }
            else
            {
                errorBlock.Visibility = Visibility.Visible;
                errorBlock.Text       = "Please enter credentials";
            }
        }