Пример #1
0
        private async void AddUserClick(object sender, RoutedEventArgs e)
        {
            string name     = userNameTb.Text;
            string email    = userEmailTb.Text;
            string password = userPasswordTb.Password.ToString();

            if (name.Equals("") || email.Equals("") || password.Equals(""))
            {
                createStatusText.Text       = "The account could not be created.";
                createStatusTextTwo.Text    = "Please enter information in all fields.";
                createStatusText.FontWeight = FontWeights.Bold;
            }
            else
            {
                if (password.Length <= 6)
                {
                    createStatusText.Text       = "The account could not be created.";
                    createStatusTextTwo.Text    = "The length of your password must be longer than 6 characters.";
                    createStatusText.FontWeight = FontWeights.Bold;
                }
                else
                {
                    if (email.Contains("@"))
                    {
                        createStatusText.Text = "Creating user...";
                        LoadingBar.IsEnabled  = true;
                        LoadingBar.Visibility = Visibility.Visible;

                        DbServiceReference.DbServiceClient dbServiceReference = new DbServiceReference.DbServiceClient();

                        bool checkIfCreated = await dbServiceReference.CreateUserAsync(name, email, password);

                        LoadingBar.IsEnabled  = false;
                        LoadingBar.Visibility = Visibility.Collapsed;

                        if (checkIfCreated == true)
                        {
                            createStatusText.Text       = "Account has successfully been created!";
                            createStatusTextTwo.Text    = "";
                            createStatusText.FontWeight = FontWeights.Normal;
                        }
                        else
                        {
                            createStatusText.Text       = $"The account could not be created.";
                            createStatusTextTwo.Text    = $"An account already exists with the email '{email}'.";
                            createStatusText.FontWeight = FontWeights.Bold;
                        }
                    }

                    else
                    {
                        createStatusText.Text       = $"The account could not be created.";
                        createStatusTextTwo.Text    = $"'{email}' is not a valid format for an email.";
                        createStatusText.FontWeight = FontWeights.Bold;
                    }
                }
            }
        }
Пример #2
0
        private async void UploadUsersClick(object sender, RoutedEventArgs e)
        {
            string path = uploadLinkTb.Text;

            if (path.Equals(""))
            {
                uploadStatusText.Text       = "The file could not be uploaded.";
                uploadStatusText.Text       = "Please enter a link to the text file.";
                uploadStatusTextTwo.Text    = "";
                uploadStatusTextThree.Text  = "";
                uploadStatusText.FontWeight = FontWeights.Bold;
            }
            else
            {
                uploadStatusText.Text = "Uploading file...";
                LoadingBar.IsEnabled  = true;
                LoadingBar.Visibility = Visibility.Visible;

                DbServiceReference.DbServiceClient dbServiceReference = new DbServiceReference.DbServiceClient();

                bool fileUploaded = await dbServiceReference.CreateUserFromTxtFileAsync(path);

                LoadingBar.IsEnabled  = false;
                LoadingBar.Visibility = Visibility.Collapsed;

                if (fileUploaded == true)
                {
                    uploadStatusText.Text       = "The users have successfully been added.";
                    uploadStatusTextTwo.Text    = "";
                    uploadStatusTextThree.Text  = "";
                    uploadStatusText.FontWeight = FontWeights.Normal;
                }
                else
                {
                    uploadStatusText.Text       = "The file could not be uploaded.";
                    uploadStatusTextTwo.Text    = $"Couldn't upload file '{path}'.";
                    uploadStatusTextThree.Text  = "The uploaded file was not valid.";
                    uploadStatusText.FontWeight = FontWeights.Bold;
                }
            }
        }
Пример #3
0
        private async void DeleteUserClick(object sender, RoutedEventArgs e)
        {
            string email = userEmailTb.Text;

            if (email.Equals(""))
            {
                deleteStatusText.Text       = "The account could not be removed.";
                deleteStatusText.Text       = "Please enter the users email.";
                deleteStatusTextTwo.Text    = "";
                deleteStatusTextThree.Text  = "";
                deleteStatusText.FontWeight = FontWeights.Bold;
            }
            else
            {
                deleteStatusText.Text = "Removing user...";
                LoadingBar.IsEnabled  = true;
                LoadingBar.Visibility = Visibility.Visible;

                DbServiceReference.DbServiceClient dbServiceReference = new DbServiceReference.DbServiceClient();

                bool checkIfDeleted = await dbServiceReference.DeleteUserAsync(email);

                LoadingBar.IsEnabled  = false;
                LoadingBar.Visibility = Visibility.Collapsed;

                if (checkIfDeleted == true)
                {
                    deleteStatusText.Text       = "Account has successfully been removed.";
                    deleteStatusTextTwo.Text    = "";
                    deleteStatusTextThree.Text  = "";
                    deleteStatusText.FontWeight = FontWeights.Normal;
                }
                else
                {
                    deleteStatusText.Text       = $"The account could not be removed.";
                    deleteStatusTextTwo.Text    = $"No user with the email '{email}' was found.";
                    deleteStatusTextThree.Text  = $"Did you enter the correct email address?";
                    deleteStatusText.FontWeight = FontWeights.Bold;
                }
            }
        }
Пример #4
0
        private async void Connect_Click(object sender, RoutedEventArgs e)
        {
            string usernameInput = usernameTxtBox.Text;
            string passwordInput = passwordTxtBox.Password.ToString();

            if (usernameInput.Equals("") || passwordInput.Equals(""))
            {
                loginStatusText.Text       = "Please enter information in all fields.";
                loginStatusText.FontWeight = FontWeights.Bold;
            }
            else
            {
                DbServiceReference.DbServiceClient dbServiceReference = new DbServiceReference.DbServiceClient();

                LoadingBar.IsEnabled  = true;
                LoadingBar.Visibility = Visibility.Visible;

                loginStatusText.Text = "You are logging in...";

                bool loginStatus = await dbServiceReference.AdminAuthAsync(usernameInput, passwordInput);

                LoadingBar.IsEnabled  = false;
                LoadingBar.Visibility = Visibility.Collapsed;

                if (loginStatus == true)
                {
                    loginStatusText.Text = "You have successfully logged in!";
                    Frame.Navigate(typeof(AdminContent));
                }
                else
                {
                    loginStatusText.Text       = " The account or password is incorrect.\nAre you sure you entered the right one?";
                    loginStatusText.FontWeight = FontWeights.Bold;
                }
            }
        }
Пример #5
0
        private async void UpdateUserClick(object sender, RoutedEventArgs e)
        {
            string email             = userEmailTb.Text;
            string password          = userPasswordTb.Password.ToString();
            string confirmedPassword = userConfirmPasswordTb.Password.ToString();

            if (password.Length <= 6)
            {
                updateStatusText.Text       = "The password could not be updated.";
                updateStatusTextTwo.Text    = "The length of your password must be longer than 6 characters.";
                updateStatusTextThree.Text  = "";
                updateStatusText.FontWeight = FontWeights.Bold;
            }

            if (email.Equals("") || password.Equals("") || confirmedPassword.Equals(""))
            {
                updateStatusText.Text       = "The password could not be updated.";
                updateStatusText.Text       = "Please enter information in all fields.";
                updateStatusTextTwo.Text    = "";
                updateStatusTextThree.Text  = "";
                updateStatusText.FontWeight = FontWeights.Bold;
            }
            else
            {
                if (password != confirmedPassword)
                {
                    updateStatusText.Text      = "The password could not be updated.";
                    updateStatusTextTwo.Text   = "The two passwords did not match.";
                    updateStatusTextThree.Text = "Did you enter the two passwords differently?";
                }
                else
                {
                    if (password.Length < 6)
                    {
                        updateStatusText.Text       = "The account could not be created.";
                        updateStatusTextTwo.Text    = "The length of your password must be longer than 6 characters.";
                        updateStatusText.FontWeight = FontWeights.Bold;
                    }
                    else
                    {
                        updateStatusText.Text = "Updating password...";
                        LoadingBar.IsEnabled  = true;
                        LoadingBar.Visibility = Visibility.Visible;

                        DbServiceReference.DbServiceClient dbServiceReference = new DbServiceReference.DbServiceClient();


                        bool checkIfUpdated = await dbServiceReference.UpdatePasswordAsync(email, confirmedPassword);

                        LoadingBar.IsEnabled  = false;
                        LoadingBar.Visibility = Visibility.Collapsed;

                        if (checkIfUpdated == true)
                        {
                            updateStatusText.Text       = "Password has successfully been updated.";
                            updateStatusTextTwo.Text    = "";
                            updateStatusTextThree.Text  = "";
                            updateStatusText.FontWeight = FontWeights.Normal;
                        }
                        else
                        {
                            updateStatusText.Text       = $"The password could not be updated.";
                            updateStatusTextTwo.Text    = $"No user with the email '{email}' was found.";
                            updateStatusTextThree.Text  = $"Did you enter the correct email address?";
                            updateStatusText.FontWeight = FontWeights.Bold;
                        }
                    }
                }
            }
        }