Exemplo n.º 1
0
        private void CreateUser(object sender, RoutedEventArgs e)
        {
            string name         = this.cuwNameField?.Text;
            string username     = this.cuwUsernameField?.Text;
            string password     = this.cuwPasswordBox?.Password;
            string errorMessage = GiftManager.HasInvalidMemberTextFields(name, username, password);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                MessageBox.Show(errorMessage);
                return;
            }
            bool[] creationInfo = GiftManager.CreateUser(name, username, password, false);
            bool   created      = creationInfo[0];
            bool   isAdminUser  = creationInfo[1];

            if (created)
            {
                if (isAdminUser)
                {
                    var dashboard = new AdminDashboard();
                    dashboard.Show();
                    this.Close();
                }
                else
                {
                    var dashboard = new Dashboard();
                    dashboard.Show();
                    this.Close();
                }
            }
        }
Exemplo n.º 2
0
        private void ReturnToDashboard(object sender, RoutedEventArgs e)
        {
            var dashboard = new AdminDashboard();

            dashboard.Show();
            this.Close();
        }
Exemplo n.º 3
0
        private void Login(object sender, RoutedEventArgs e)
        {
            string       username = this.mwUsernameField?.Text;
            SecureString password = this.mwPasswordBox?.SecurePassword;

            bool[] login       = GiftManager.Login(username, password);
            bool   isLoggedIn  = login[0];
            bool   isAdminUser = login[1];

            if (isLoggedIn)
            {
                if (isAdminUser)
                {
                    var dashboard = new AdminDashboard {
                        CurrentUsername = username
                    };
                    dashboard.Show();
                    this.Close();
                }
                else
                {
                    var dashboard = new Dashboard {
                        CurrentUsername = username
                    };
                    dashboard.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Username or password was not correct", "Login Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
        }