public bool LoginUserCheck()
        {
            var          myDbConnection = new ServerAccess();
            PasswordHash checkPassword  = new PasswordHash();

            hashedPassword = checkPassword.HashPassword(Password, GetSalt());

            using (myDbConnection.DBConnect)
            {
                bool exists;

                using (MySqlCommand checkLogin = new MySqlCommand(userCheckQuery, myDbConnection.DBConnect))
                {
                    checkLogin.Parameters.AddWithValue("@email", Email);
                    checkLogin.Parameters.AddWithValue("@password", hashedPassword);
                    myDbConnection.DBConnect.Open();
                    int TotalRows = 0;
                    TotalRows = Convert.ToInt32(checkLogin.ExecuteScalar());

                    if (TotalRows > 0)
                    {
                        exists = true;
                    }
                    else
                    {
                        exists = false;
                    }
                }

                myDbConnection.DBConnect.Close();
                return(exists);
            }
        }
        public void InsertNewUser()
        {
            var          myDbConnection         = new ServerAccess();
            PasswordHash passwordHashing        = new PasswordHash();
            string       salty                  = passwordHashing.CreateSalt(48);
            string       generateHashedPassword = passwordHashing.HashPassword(Password, salty);

            using (myDbConnection.DBConnect)
            {
                myDbConnection.DBConnect.Open();

                using (MySqlCommand newUserCommand = new MySqlCommand("NewUser", myDbConnection.DBConnect))
                {
                    newUserCommand.CommandType = CommandType.StoredProcedure;

                    newUserCommand.Parameters.AddWithValue("email", Email);
                    newUserCommand.Parameters.AddWithValue("password", generateHashedPassword);
                    newUserCommand.Parameters.AddWithValue("username", Username);
                    newUserCommand.Parameters.AddWithValue("Salt", salty);

                    newUserCommand.ExecuteNonQuery();
                }
            }

            myDbConnection.DBConnect.Close();
        }
        public bool checkUser()
        {
            var myDbConnection = new ServerAccess();


            using (myDbConnection.DBConnect)
            {
                bool exists;

                using (MySqlCommand checkUserCommand = new MySqlCommand(checkAvailableUsers, myDbConnection.DBConnect))
                {
                    checkUserCommand.Parameters.AddWithValue("@email", Email);
                    checkUserCommand.Parameters.AddWithValue("@usrname", Username);
                    myDbConnection.DBConnect.Open();
                    int TotalRows = 0;
                    TotalRows = Convert.ToInt32(checkUserCommand.ExecuteScalar());

                    if (TotalRows > 0)
                    {
                        exists = true;
                    }
                    else
                    {
                        exists = false;
                    }
                }

                myDbConnection.DBConnect.Close();
                return(exists);
            }
        }
        public bool ExistingPassword()
        {
            var myDbConnection = new ServerAccess();


            using (myDbConnection.DBConnect)
            {
                using (MySqlCommand checkUserPassword = new MySqlCommand(passwordCheckString, myDbConnection.DBConnect))
                {
                    checkUserPassword.Parameters.AddWithValue("@email", givenEmail);
                    myDbConnection.DBConnect.Open();
                    MySqlDataReader reader = checkUserPassword.ExecuteReader();
                    while (reader.Read())
                    {
                        oldPassword = (string)reader["Password"];
                    }
                }


                myDbConnection.DBConnect.Close();

                if (oldPassword == ConvertNewPassword(newPassword))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
        public void ChangePassword()
        {
            var myDbConnection = new ServerAccess();


            using (myDbConnection.DBConnect)
            {
                using (MySqlCommand updatePassword = new MySqlCommand("ChangePassword", myDbConnection.DBConnect))
                {
                    myDbConnection.DBConnect.Open();
                    updatePassword.CommandType = CommandType.StoredProcedure;
                    updatePassword.Parameters.AddWithValue("email", givenEmail);
                    updatePassword.Parameters.AddWithValue("password", ConvertNewPassword(newPassword));
                    updatePassword.ExecuteNonQuery();
                }

                myDbConnection.DBConnect.Close();
            }
        }
        public string GetSalt()
        {
            var myDbConnection = new ServerAccess();

            using (myDbConnection.DBConnect)
            {
                using (MySqlCommand getSalt = new MySqlCommand(getSaltCode, myDbConnection.DBConnect))
                {
                    getSalt.Parameters.AddWithValue("@email", Email);
                    myDbConnection.DBConnect.Open();

                    MySqlDataReader reader = getSalt.ExecuteReader();
                    saltCode = null;
                    if (reader.Read())
                    {
                        saltCode = reader.GetString(0);
                    }
                }
                myDbConnection.DBConnect.Close();
                return(saltCode);
            }
        }