Esempio n. 1
0
        //Eventhandler for pressing the login button
        private void logInButton_Click(object sender, RoutedEventArgs e)
        {
            //Check to see if the profile that the user has entered exists in the database.
            if (!userProcessor.checkConection())
            {
                ExceptionMessage dialogBox = new ExceptionMessage("Could not connect to MongoDB. Make sure you have an instance of MongoDB running.", "Not connected");
                dialogBox.ShowDialog();
                return;
            }
            Tuple <bool, string> userCheckResult = userProcessor.checkProfile(userName.Text, password.SecurePassword);

            if (userCheckResult.Item1)
            {
                DiscogsMain discogsWin = new DiscogsMain(userProcessor.getClient());
                discogsWin.Show();
                this.Close();
                return;
            }
            else
            {
                ExceptionMessage dialogBox = new ExceptionMessage("The username/password combination was not found.", "Invalid username/password");
                dialogBox.ShowDialog();
                return;
            }
        }
        private void createUser_Click(object sender, RoutedEventArgs e)
        {
            Tuple <bool, string> result = userProcessor.insertProfile(userName.Text, password.SecurePassword);

            if (!result.Item1)
            {
                ExceptionMessage popUp = new ExceptionMessage(result.Item2, "Failed to create user");
                popUp.ShowDialog();
            }
            else
            {
                if (userProcessor.checkProfile(userName.Text, password.SecurePassword).Item1)
                {
                    DiscogsMain discogsWin = new DiscogsMain(userProcessor.getClient());
                    discogsWin.Show();
                    this.Close();
                    return;
                }
            }
        }