Пример #1
0
        private void ButtonYes_Click(object sender, RoutedEventArgs e)
        {
            Task.Run(() =>
            {
                string postData    = $"del=1&un={logInObjectUsable.user.username}&wln={wishListItem.wishListName}&win={wishListItem.wishItemName}";
                string method      = "POST";
                string phpFileName = "delWish.php";

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

                var deleteItemObj = JsonConvert.DeserializeObject <DeleteItemObj>(jsonStr);

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

                        Close();
                    });
                }
                else
                {
                    Dispatcher.Invoke(() =>
                    {
                        LabelUserInteractionFeedback.Foreground = Brushes.LightPink;
                        LabelUserInteractionFeedback.Content    = $"Error: {deleteItemObj.msg}";
                    });
                }
            });
        }
Пример #2
0
        private void FillFriendList()
        {
            string postData    = "un=" + logInObject.user.username;
            string method      = "POST";
            string phpFileName = "getFriendList.php";

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

            var sharedListObject = JsonConvert.DeserializeObject <SharedListObject>(jsonStr);

            if (sharedListObject.friends == null)
            {
                //this.Close();
                Dispatcher.Invoke(() =>
                {
                    ListBoxFriends.Items.Add("null");
                });
            }
            else
            {
                foreach (var friend in sharedListObject.friends)
                {
                    Dispatcher.Invoke(() =>
                    {
                        ListBoxFriends.Items.Add(friend);
                    });
                }
            }
        }
Пример #3
0
        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";
                });
            }
        }
Пример #4
0
        private ObjectOfWishLists GetListofLists(User user)
        {
            string postData    = "un=" + user.username;
            string method      = "POST";
            string phpFileName = "getLists.php";

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

            ObjectOfWishLists ListOfLists = JsonConvert.DeserializeObject <ObjectOfWishLists>(jsonStr);

            return(ListOfLists);
        }
Пример #5
0
        public void HttpRequest(string userName, string password)
        {
            Task.Run(() =>
            {
                string postData    = "un=" + userName + "&pw=" + password;
                string method      = "POST";
                string phpFileName = "login.php";

                string jsonStr = "";
                string error   = "";
                try
                {
                    jsonStr = WebReq.WebRq(postData, method, phpFileName, "");
                }
                catch (System.Exception e)
                {
                    error = e.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;
                    });
                }
            });
        }
Пример #6
0
        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}";
                        });
                    }
                });
            }
        }
Пример #7
0
        private void ButtonShare_Click(object sender, RoutedEventArgs e)
        {
            FriendListRequest friendListRequest = new FriendListRequest();

            friendListRequest.un  = logInObject.user.username;
            friendListRequest.wln = ComboBoxSelectWishList.SelectedItem.ToString();
            friendListRequest.sun = new List <string>();
            foreach (var friend in ListBoxFriends.SelectedItems)
            {
                friendListRequest.sun.Add(friend.ToString());
            }

            string output = JsonConvert.SerializeObject(friendListRequest);

            string postData    = output;
            string method      = "POST";
            string phpFileName = "shareWishList.php";

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

            var shareObject = JsonConvert.DeserializeObject <ShareObject>(jsonStr);

            if (shareObject.friends == null)
            {
                this.Close();
            }
            else
            {
                string list = "";
                foreach (var friend in shareObject.friends)
                {
                    list += " " + friend.shareToUser;
                }
                MessageBox.Show(shareObject.msg + "\n" + list);
            }
        }
Пример #8
0
        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.";
                            }
                        }
                    });
                }
            }
        }