コード例 #1
0
ファイル: NewWishList.xaml.cs プロジェクト: otto-r/WinWishApp
        private void ButtonAddNewList_Click(object sender, RoutedEventArgs e)
        {
            string userWishListNameInput = TextBoxWishListName.Text.Trim();

            if (UserInputValidation.InputValidator(userWishListNameInput, true).ValidInput&& !SeeIfWishListNameExists())
            {
                Task.Run(() =>
                {
                    string postData    = "un=" + logInObjectUsable.user.username + "&wln=" + userWishListNameInput;
                    string method      = "POST";
                    string phpFileName = "addWishList.php";

                    string jsonStr = WebReq.WebRq(postData, method, phpFileName, "");

                    var addNewWishListObj = JsonConvert.DeserializeObject <AddNewWishListObj>(jsonStr);

                    if (addNewWishListObj.success == 1)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            LabelUserInputvalidation.Foreground = Brushes.LightGreen;
                            LabelUserInputvalidation.Content    = "Successful";

                            this.Close();
                        });
                    }
                    else
                    {
                        Dispatcher.Invoke(() =>
                        {
                            LabelUserInputvalidation.Foreground = Brushes.LightPink;
                            LabelUserInputvalidation.Content    = $"Error: {addNewWishListObj.msg}";
                        });
                    }
                });
            }
            else if (SeeIfWishListNameExists())
            {
                Dispatcher.Invoke(() =>
                {
                    LabelUserInputvalidation.Foreground = Brushes.LightPink;
                    LabelUserInputvalidation.Content    = $"A list by the name {userWishListNameInput} already exists";
                });
            }
            else
            {
                Dispatcher.Invoke(() =>
                {
                    LabelUserInputvalidation.Foreground = Brushes.LightPink;
                    LabelUserInputvalidation.Content    = "Invalid characters";
                });
            }
        }
コード例 #2
0
ファイル: NewItem.xaml.cs プロジェクト: otto-r/WinWishApp
        private void ButtonAddWish_Click(object sender, RoutedEventArgs e)
        {
            string wishName        = TextBoxNameOfWishItem.Text;
            string wishListName    = ComboBoxSelectWishList.SelectedItem.ToString();
            string wishDescription = TextBoxItemDescription.Text;
            string wishAvailableAt = TextBoxItemAvailableAt.Text;

            if (UserInputValidation.InputValidator(wishName, true).ValidInput)
            {
                Task.Run(() =>
                {
                    string postData    = $"un={logInObjectUsable.user.username}&wln={wishListName}&win={wishName}&widesc={wishDescription}&wiaa={wishAvailableAt}";
                    string method      = "POST";
                    string phpFileName = "addWish.php";

                    string jsonStr = WebReq.WebRq(postData, method, phpFileName, "");

                    var addNewWishObj = JsonConvert.DeserializeObject <AddNewWishObj>(jsonStr);

                    if (addNewWishObj.success == 1)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            LabelUserInteractionFeedBack.Foreground = Brushes.LightGreen;
                            LabelUserInteractionFeedBack.Content    = "Successful";

                            this.Close();
                        });
                    }
                    else
                    {
                        Dispatcher.Invoke(() =>
                        {
                            LabelUserInteractionFeedBack.Foreground = Brushes.LightPink;
                            LabelUserInteractionFeedBack.Content    = $"Error: {addNewWishObj.msg}";
                        });
                    }
                });
            }
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: otto-r/WinWishApp
        private void ButtonRegister_Click(object sender, RoutedEventArgs e)
        {
            userName       = TextBoxUserName.Text;
            password       = PasswordBox.Password;
            reTypePassword = PasswordBoxRetype.Password;
            eMail          = TextBoxEmail.Text;
            reTypeEMail    = TextBoxEmailRetype.Text;

            if (showRegistrationFields == false)
            {
                showRegistrationFields = true;
                ShowRegistration();
            }
            else
            {
                if (UserInputValidation.InputValidator(userName, false).ValidInput)
                {
                    Task.Run(() =>
                    {
                        string postData    = "un=" + userName + "&pw=" + password + "&email=" + eMail;
                        string method      = "POST";
                        string phpFileName = "regUser.php";
                        //WebReq.WebRq(postData, method, phpFileName);
                        string jsonStr = "";
                        string error   = "";

                        if (eMail == reTypeEMail && password == reTypePassword)
                        {
                            try
                            {
                                jsonStr = WebReq.WebRq(postData, method, phpFileName, "");
                            }
                            catch (System.Exception err)
                            {
                                error = err.ToString();
                                Task.Run(() =>
                                {
                                    InfoBarAsync("", error);
                                    errorMessage   = error;
                                    loadingLabelOn = false;
                                });
                            }

                            LogInObject logInUserObject = JsonConvert.DeserializeObject <LogInObject>(jsonStr);


                            if (logInUserObject.success == 1)
                            {
                                Dispatcher.Invoke(() =>
                                {
                                    LoggedInWindow mainLogInWindow = new LoggedInWindow(logInUserObject);
                                    mainLogInWindow.Show();
                                    this.Close();
                                });
                            }
                            else if (logInUserObject.success != 1)
                            {
                                Task.Run(() =>
                                {
                                    InfoBarAsync("", logInUserObject.msg);
                                    loadingLabelOn = false;
                                });
                            }
                        }
                        else
                        {
                            if (eMail != reTypeEMail)
                            {
                                InfoBarAsync("", "E-mails do not match.");
                                errorMessage = "E-mails do not match.";
                            }
                            else
                            {
                                InfoBarAsync("", "Passwords do not match.");
                                errorMessage = "Passwords do not match.";
                            }
                        }
                    });
                }
            }
        }