Beispiel #1
0
        //Creates a page with a chatpartner. Own data to be retrieved via User.
        public ChatPage(UserData chatPartner)
        {
            //fix selfcert error
            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            InitializeComponent();
            this.chatPartner     = chatPartner;
            ChatPartnerName.Text = chatPartner.realName;
            string chatPartnerPicture = $"https://145.44.233.207/images/users/{chatPartner.profilePicture}";

            ChatPartnerPicture.Fill = new ImageBrush(new BitmapImage(new Uri(chatPartnerPicture, UriKind.Absolute)));
            this.userInChat         = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));
            //determines chatid -> id = lowerid + space + higherid
            if (int.Parse(userInChat.id) < int.Parse(chatPartner.id))
            {
                chatID     = $"{userInChat.id}_{chatPartner.id}";
                userSender = 0;
            }
            else
            {
                chatID     = $"{chatPartner.id}_{userInChat.id}";
                userSender = 1;
            }
            UpdateScrollBox();
            SetTimer();
        }
        //Menu buttons
        //Go to Notification page
        private void Notification_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Notifications notifications = new Notifications(MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.ID)));

            notifications.Title = "Notifications";
            NavigationService.Navigate(notifications);
        }
        public async void FillEmptyList(UserData getLoggedInUserData)
        {
            List <int> temporarilyList = new List <int>();

            getLoggedInUserData.blockedUsers = temporarilyList;
            await MatchmakerAPI_Client.SaveUser(getLoggedInUserData);
        }
        //Go to own profilepage
        private void MyProfile_MouseDown(object sender, MouseButtonEventArgs e)
        {
            UserData user        = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));
            Page     userProfile = new UserProfile(user, true, int.Parse(LoggedInUser.id));

            NavigationService.Navigate(userProfile);
        }
        public Notifications(UserData currentUser)
        {
            InitializeComponent();

            this.currentUser = currentUser;

            //Load notifications (chats with unread messages)
            NotificationList.ItemsSource = MatchmakerAPI_Client.LoadNotifications(currentUser).Result;
        }
 public ChatListPage(UserData user)
 {
     LoggedInUser = user;
     InitializeComponent();
     NewRequests();
     ChatList();
     UserContacts();
     LoadBlockedUsers();
     RefreshNotificationCount(MatchmakerAPI_Client.GetNotificationCount(LoggedInUser));
 }
        public void MatchmakerAPI_DeserializeUserData_returnsDeserializedData()
        {
            //test data
            string user = MatchmakerAPI_Client.GetUserData("*****@*****.**");
            //act
            UserData result = MatchMakerClassLibrary.MatchmakerAPI_Client.DeserializeUserData(user);

            //test
            Assert.IsTrue(result.realName == "Guus Apeldoorn");
        }
        public void MatchmakerAPI_Client_DeserializeMessageData_createNewDataWhenJsonIsNull()
        {
            //data
            string json = null;
            //act
            var result = MatchmakerAPI_Client.DeserializeMessageData(json);

            //test
            Assert.IsTrue(result.Count == 0);
        }
Beispiel #9
0
 private async void confirmNewLocation_Click(object sender, RoutedEventArgs e)
 {
     city.Text       = citySelection.SelectedItem.ToString();
     userInView.city = citySelection.SelectedItem.ToString();
     confirmNewLocation.Visibility = Visibility.Collapsed;
     denyLocationChange.Visibility = Visibility.Collapsed;
     editLocation.Visibility       = Visibility.Visible;
     citySelection.Visibility      = Visibility.Collapsed;
     city.Visibility = Visibility.Visible;
     await MatchmakerAPI_Client.SaveUser(userInView);
 }
Beispiel #10
0
 //Edit the About me section of an application
 private async void confirmBioChange_Click(object sender, RoutedEventArgs e)
 {
     userInView.about            = accountText.Text;
     bioText.Text                = accountText.Text;
     denyBioChange.Visibility    = Visibility.Collapsed;
     confirmBioChange.Visibility = Visibility.Collapsed;
     accountText.Visibility      = Visibility.Collapsed;
     bioText.Visibility          = Visibility.Visible;
     editBio.Visibility          = Visibility.Visible;
     await MatchmakerAPI_Client.SaveUser(userInView);
 }
        // Display your contacts
        public void UserContacts()
        {
            UserData loggedInUser = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));
            Dictionary <string, bool> contacts = loggedInUser.contacts;

            try
            {
                if (contacts.Count > 0 && contacts != null) // check if there are contacts in the dictionary
                {
                    foreach (var contact in contacts)
                    {
                        UserData contactUser = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(int.Parse(contact.Key)));
                        if (contactUser != null && contact.Value == true)
                        {
                            string     panelName = contactUser.id;
                            StackPanel userBlock = new StackPanel()
                            {
                                Margin = new Thickness(0, 20, 0, 0), Width = 120, Name = $"_{panelName}"
                            };
                            Ellipse userProfilePicture = new Ellipse()
                            {
                                Height = 54, Width = 54, Name = $"_{panelName}"
                            };
                            string pfPic1 = $"https://145.44.233.207/images/users/{contactUser.profilePicture}";
                            userProfilePicture.Fill = new ImageBrush(new BitmapImage(new Uri(pfPic1, UriKind.Absolute)));
                            TextBlock userRealName = new TextBlock()
                            {
                                Text = contactUser.realName, FontSize = 16, LineHeight = 20, Opacity = 0.87, Width = 110, TextAlignment = TextAlignment.Center, Margin = new Thickness(0, 8, 0, 0), TextWrapping = TextWrapping.Wrap
                            };

                            userBlock.Children.Add(userProfilePicture);
                            userBlock.Children.Add(userRealName);
                            userBlock.MouseDown += NewChat_MouseDown;
                            recentlyAddedChats.Children.Add(userBlock);
                        }
                    }
                }
                else
                {
                    recentlyAddedChats.Children.Add(new TextBlock()
                    {
                        FontSize = 14, Text = "You have no contacts.", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center, Width = 520
                    });
                }
            }
            catch (NullReferenceException)
            {
                recentlyAddedChats.Children.Add(new TextBlock()
                {
                    FontSize = 14, Text = "You have no contacts.", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, TextAlignment = TextAlignment.Center, Width = 520
                });
            }
        }
        // Receives the id of the user and opens a new chat page
        private void OpenChat_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var    clickedChat = e.Source as FrameworkElement; // get the element that is clicked on and store this in the temp var
            string idOfClick   = clickedChat.Name;

            idOfClick = idOfClick.Replace("_", "");                                                                                  // _ is removed from the string

            UserData chatPartner = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(int.Parse(idOfClick))); // get the userdata from the database
            ChatPage chat        = new ChatPage(chatPartner);

            NavigationService.Navigate(chat);
        }
        //Refresh the notifications and animate the refresh button
        private void RefreshNotificationsButton_MouseDown(object sender, MouseButtonEventArgs e)
        {
            NotificationList.ItemsSource = MatchmakerAPI_Client.LoadNotifications(currentUser).Result;

            for (int i = 0; i < 360; i += 10)
            {
                RotateTransform rotateTransform = new RotateTransform(i);
                RefreshNotificationsButton.RenderTransform = rotateTransform;
                Thread.Sleep(25);
                System.Windows.Forms.Application.DoEvents();
            }
        }
        // The contact request is accepted
        private async void ContactRequestAccept(object sender, RoutedEventArgs e)
        {
            //Get sender ID
            var button = (Button)sender;
            int id     = int.Parse(button.Name.Replace("_", String.Empty));

            UserData loggedInUser = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.ID)); // This person received a contact request.
            UserData userSender   = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(id));      // This person has send a contact request.
            await MatchmakerAPI_Client.ConfirmContactRequest(loggedInUser, userSender);


            NavigationService.Navigate(this);
        }
        // Decline the contact request
        private async void ContactRequestDecline(object sender, RoutedEventArgs e)
        {
            //Get sender ID
            var button = (Button)sender;
            int id     = int.Parse(button.Name.Replace("_", string.Empty));

            UserData loggedInUser = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.ID)); // This person received a contact request.
            UserData userSender   = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(id));      // This person that send a contact request.
            await MatchmakerAPI_Client.declineContactRequest(loggedInUser, userSender);                                  // contact request is declined

            ChatListPage chatList = new ChatListPage(loggedInUser);

            NavigationService.Navigate(chatList);
        }
        private void FillHomepageProfiles(UserData[] userDatas)
        {
            RefreshNotificationCount(MatchmakerAPI_Client.GetNotificationCount(LoggedInUser));

            FirstProfile = userDatas[0];
            //Set name
            Profile1Tag.Content = userDatas[0].realName;
            //Set profile picture
            string pfPic1 = $"https://145.44.233.207/images/users/{userDatas[0].profilePicture}";

            ProfilePicture1.Fill = new ImageBrush(new BitmapImage(new Uri(pfPic1, UriKind.Absolute)));
            //Set Cover Image
            string coverImage = $"https://145.44.233.207/images/covers/{userDatas[0].coverImage}";

            Profile1BackgroundPicture.Background = new ImageBrush(new BitmapImage(new Uri(coverImage, UriKind.Absolute)));

            SecondProfile = userDatas[1];
            //Set name
            Profile2Tag.Content = userDatas[1].realName;
            //Set profile picture
            string pfPic2 = $"https://145.44.233.207/images/users/{userDatas[1].profilePicture}";

            ProfilePicture2.Fill = new ImageBrush(new BitmapImage(new Uri(pfPic2, UriKind.Absolute)));
            //Set Cover Image
            coverImage = $"https://145.44.233.207/images/covers/{userDatas[1].coverImage}";
            Profile2BackgroundPicture.Background = new ImageBrush(new BitmapImage(new Uri(coverImage, UriKind.Absolute)));

            ThirdProfile = userDatas[2];
            //Set name
            Profile3Tag.Content = userDatas[2].realName;
            //Set profile picture
            string pfPic3 = $"https://145.44.233.207/images/users/{userDatas[2].profilePicture}";

            ProfilePicture3.Fill = new ImageBrush(new BitmapImage(new Uri(pfPic3, UriKind.Absolute)));
            //Set Cover Image
            coverImage = $"https://145.44.233.207/images/covers/{userDatas[2].coverImage}";
            Profile3BackgroundPicture.Background = new ImageBrush(new BitmapImage(new Uri(coverImage, UriKind.Absolute)));

            FourthProfile = userDatas[3];
            //Set name
            Profile4Tag.Content = userDatas[3].realName;
            //Set profile picture
            string pfPic4 = $"https://145.44.233.207/images/users/{userDatas[3].profilePicture}";

            ProfilePicture4.Fill = new ImageBrush(new BitmapImage(new Uri(pfPic4, UriKind.Absolute)));
            //Set Cover Image
            coverImage = $"https://145.44.233.207/images/covers/{userDatas[3].coverImage}";
            Profile4BackgroundPicture.Background = new ImageBrush(new BitmapImage(new Uri(coverImage, UriKind.Absolute)));
        }
Beispiel #17
0
        //This method Updates the scrollable chatbox and scrolls to the bottom.
        private async void UpdateScrollBox()
        {
            var newMessageList = new List <MessageData>();

            newMessageList = MatchmakerAPI_Client.DeserializeMessageData(await MatchmakerAPI_Client.GetMessageData(chatID));
            if (newMessageList.Count() != messageList.Count())
            {
                newMessageList = newMessageList.OrderBy(msg => msg.timestamp).ToList();
                messageList    = newMessageList;
                MessageList.Children.Clear();
                FillScrollBox();
                ScrollViewer.ScrollToEnd();
                MatchmakerAPI_Client.SetToRead(chatID, userSender);
            }
        }
        // Display the blocked users
        public void LoadBlockedUsers()
        {
            UserData loggedInUser = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));

            List <int> blockedUsers = loggedInUser.blockedUsers;

            if (blockedUsers.Count > 0 && blockedUsers != null) // check if the there are any blocked users
            {
                for (int i = 0; i < blockedUsers.Count; i++)
                {
                    UserData user = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(blockedUsers[i]));

                    Grid blockedUser = new Grid()
                    {
                        Height = 70
                    };
                    WrapPanel userWrapper        = new WrapPanel();
                    Ellipse   userProfilePicture = new Ellipse()
                    {
                        Height = 54, Width = 54, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0, 12, 8, 0)
                    };
                    string pfPic1 = $"https://145.44.233.207/images/users/{user.profilePicture}";
                    userProfilePicture.Fill = new ImageBrush(new BitmapImage(new Uri(pfPic1, UriKind.Absolute)));
                    TextBlock userRealName = new TextBlock()
                    {
                        Text = user.realName, FontSize = 16, LineHeight = 20, Opacity = 0.87, TextAlignment = TextAlignment.Center, Margin = new Thickness(0, 16, 0, 0), VerticalAlignment = VerticalAlignment.Center
                    };
                    Button deblock = new Button()
                    {
                        Name = $"_{i}", Content = "Unblock", Background = MediaBrush.Transparent, BorderThickness = new Thickness(0), Foreground = MediaBrush.Purple, HorizontalAlignment = HorizontalAlignment.Right
                    };
                    deblock.Click += Deblock_Click;

                    userWrapper.Children.Add(userProfilePicture);
                    userWrapper.Children.Add(userRealName);
                    blockedUser.Children.Add(userWrapper);
                    blockedUser.Children.Add(deblock);
                    blockedUserList.Children.Add(blockedUser);
                }
            }
            else
            {
                blockedUserList.Children.Add(new TextBlock()
                {
                    FontSize = 14, Text = "You have blocked no users.", HorizontalAlignment = HorizontalAlignment.Center, TextAlignment = TextAlignment.Center, Width = 490
                });
            }
        }
Beispiel #19
0
        public CoverImageSelecter()
        {
            InitializeComponent();
            List <Img> images = new List <Img>();

            //Get the cover images available
            Dictionary <string, string> coverImages = MatchmakerAPI_Client.GetCoverImages();

            foreach (KeyValuePair <string, string> keyValue in coverImages)
            {
                images.Add(new Img(keyValue));
            }

            //Add the images to the list in the window
            ImageList.ItemsSource = images;
        }
Beispiel #20
0
        //add an hobby button event
        public void addHobbyToList_Click(object sender, RoutedEventArgs e)
        {
            List <HobbyData> listAllHobbies = MatchmakerAPI_Client.getAllHobbies();
            string           name           = (e.Source as CheckBox).Name.ToString();
            string           idName         = name.Substring(2);
            int id = Int32.Parse(idName);

            if ((sender as CheckBox).IsChecked == true)
            {
                hobbyData.Add(listAllHobbies[id]);
            }
            else
            {
                hobbyData.Remove(listAllHobbies[id]);
            }
        }
        // This method is the activation for deblocking the user.
        private async void Deblock_Click(object sender, RoutedEventArgs e)
        {
            UserData   loggedInUser = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));
            List <int> blockedUsers = loggedInUser.blockedUsers;
            var        number       = (Button)sender; // get the name of the button that is clicked
            int        listIndex    = int.Parse(number.Name.Replace("_", string.Empty));

            blockedUsers.RemoveAt(listIndex);
            loggedInUser.blockedUsers = blockedUsers;

            await MatchmakerAPI_Client.SaveUser(loggedInUser);

            // after the await the page is updated and the user is not in the blocked list anymore.
            ChatListPage chatList = new ChatListPage(loggedInUser);

            NavigationService.Navigate(chatList);
        }
Beispiel #22
0
        //This method will send a message. This method will be used inside other methods.
        //Still needs connection to server.
        private async Task <bool> SendMessageAsync()
        {
            //creates unixtimestamp to the current time.
            long now = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            //creates message and sends it to the server. Clears inputfield afterwards
            //MessageData msgD = new MessageData() { ID = chatID, Sender=userSender, TimeStamp=now, Text=ChatInput.Text };
            MessageData msgD = new MessageData()
            {
                ID = chatID, message = ChatInput.Text, timestamp = now, sender = userSender, seen = false
            };
            NewMessageData nMsgD = new NewMessageData()
            {
                chat = chatID, content = msgD
            };
            await MatchmakerAPI_Client.PostNewMessage(nMsgD);

            ChatInput.Clear();
            return(true);
        }
Beispiel #23
0
        //Send a contact request to an other user
        private async void contactRequest_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // check if a list of contacts is not created
            if (userInView.contacts == null)
            {
                Dictionary <string, bool> x = new Dictionary <string, bool>();
                userInView.contacts = x;
            }

            // if the user is not in the list of contacts create a new request
            if ((!userInView.contacts.ContainsKey(userInView.id)))
            {
                contactRequest.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#b3aead"));

                //Save userID on others requestList

                //Check if list already exists
                if (userInView.requestFrom == null)
                {
                    List <int> x = new List <int>();
                    userInView.requestFrom = x;
                }
                //If there is no contact request yet, add a new contact request
                if (!userInView.requestFrom.Contains(LoggedInUserID))
                {
                    userInView.requestFrom.Add(LoggedInUserID);
                    UserData userLoggedIn = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.ID));

                    if (userLoggedIn.contacts == null)
                    {
                        Dictionary <string, bool> x = new Dictionary <string, bool>();
                        userLoggedIn.contacts = x;
                    }

                    userLoggedIn.contacts.Add(userInView.id, false);

                    await MatchmakerAPI_Client.SaveUser(userInView);

                    await MatchmakerAPI_Client.SaveUser(userLoggedIn);
                }
            }
        }
        public HomePage()
        {
            //Start application
            InitializeComponent();

            //Gather info about logged-in user
            string   email = User.email;
            UserData getLoggedInUserData = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(email));

            LoggedInUser = getLoggedInUserData;
            User.ID      = int.Parse(LoggedInUser.id);

            if (getLoggedInUserData.blockedUsers == null)
            {
                FillEmptyList(getLoggedInUserData);
            }

            //Display the recommended users
            FillHomepageProfiles(GenerateUserDatas());
        }
        private async void NewChat_MouseDown(object sender, MouseButtonEventArgs e)
        {
            // Create a new chat.

            var    clickedContact = e.Source as FrameworkElement;
            string idOfClick      = clickedContact.Name;

            idOfClick = idOfClick.Replace("_", "");

            UserData user = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));

            string chatId; // the id for every chat. this is a combination of the user id of the logged in user and the selected user to chat with.

            if (int.Parse(user.id) < int.Parse(idOfClick))
            {
                chatId = $"{user.id}_{idOfClick}";
            }
            else
            {
                chatId = $"{idOfClick}_{user.id}";
            }

            var messageList = new List <MessageData>();

            //get message list from server
            messageList = MatchmakerAPI_Client.DeserializeMessageData(await MatchmakerAPI_Client.GetMessageData(chatId));
            UserData newContactChat = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(int.Parse(idOfClick)));

            ClickedUser = newContactChat;

            if (messageList.Count <= 0) // open the overlay if there is no messagedata or go to the profile of the selected user.
            {
                overlay.Visibility         = Visibility.Visible;
                decideOnProfile.Visibility = Visibility.Visible;
            }
            else
            {
                UserProfile contactProfile = new UserProfile(newContactChat, false, User.ID);
                NavigationService.Navigate(contactProfile);
            }
        }
Beispiel #26
0
        //remove a hobby from the account
        private async void RemoveHobby_MouseDown(object sender, MouseButtonEventArgs e)
        {
            string name  = (e.Source as Path).Name.ToString();
            string hobby = restoreName(name);

            for (int i = 0; i < userInView.hobbies.Count; i++)
            {
                if (userInView.hobbies[i].displayName == hobby)
                {
                    userInView.hobbies.Remove(userInView.hobbies[i]);
                }
            }

            await MatchmakerAPI_Client.SaveUser(userInView);

            //Reload the page
            UserData user        = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));
            Page     userProfile = new UserProfile(user, true, LoggedInUserID);

            NavigationService.Navigate(userProfile);
        }
Beispiel #27
0
 private async void confirmNameChange_Click(object sender, RoutedEventArgs e)
 {
     //Check if the input is empty
     if (name.Text.Trim() == "" || name.Text == null)
     {
         MessageBox.Show("The new name cannot be empty");
         name.Text = userInView.realName;
     }
     else if (name.Text != null && name.Text.Trim() != "")
     {
         userInView.realName          = name.Text;
         showName.Text                = name.Text;
         userInView.realName          = name.Text;
         showName.Visibility          = Visibility.Visible;
         editName.Visibility          = Visibility.Visible;
         name.Visibility              = Visibility.Collapsed;
         confirmNameChange.Visibility = Visibility.Collapsed;
         denymNameChange.Visibility   = Visibility.Collapsed;
         await MatchmakerAPI_Client.SaveUser(userInView);
     }
 }
Beispiel #28
0
        //lead a list with hobbies
        private void LoadHobbies()
        {
            List <HobbyData> listHobbies = MatchmakerAPI_Client.getAllHobbies();

            for (int i = 0; i < listHobbies.Count(); i++)
            {
                CheckBox  cb        = new CheckBox();
                TextBlock tb        = new TextBlock();
                Grid      hobbyLane = new Grid();
                //Generate the list of hobbies and the UI elements for them
                tb.Text                = listHobbies[i].displayName;
                tb.FontSize            = 14;
                tb.Name                = $"tb{i}";
                tb.HorizontalAlignment = HorizontalAlignment.Left;
                cb.Name                = $"cb{i}";
                if (userInView.hobbies != null)
                {
                    foreach (var item in userInView.hobbies)
                    {
                        if (listHobbies[i].displayName == item.displayName)
                        {
                            cb.IsChecked = true;
                        }
                    }
                }
                cb.Click += new RoutedEventHandler(addHobbyToList_Click);
                cb.HorizontalAlignment = HorizontalAlignment.Right;
                cb.VerticalAlignment   = VerticalAlignment.Center;
                //Add the elements to the UI
                hobbyLane.Children.Add(tb);
                hobbyLane.Children.Add(cb);
                hobbyLane.Height = 25;
                hobbyLane.HorizontalAlignment = HorizontalAlignment.Stretch;

                listPossibleInterests.Children.Add(hobbyLane);
            }
        }
Beispiel #29
0
        //Add hobbies to an account
        private async void AddInterests_Click(object sender, RoutedEventArgs e)
        {
            AddHobbies.Visibility            = Visibility.Collapsed;
            entryHobbies.Visibility          = Visibility.Collapsed;
            addInterests.Visibility          = Visibility.Collapsed;
            listPossibleInterests.Visibility = Visibility.Collapsed;
            bool inAccount;

            if (userInView.hobbies == null)
            {
                userInView.hobbies = new List <HobbyData>();
            }
            foreach (var item in hobbyData)
            {
                inAccount = false;
                foreach (var hobby in userInView.hobbies)
                {
                    if (hobby.displayName == item.displayName)
                    {
                        inAccount = true;
                    }
                }
                if (inAccount == false)
                {
                    userInView.hobbies.Add(item);
                }
            }

            await MatchmakerAPI_Client.SaveUser(userInView);

            //Reload page
            hobbyData = new List <HobbyData>();
            UserData user        = MatchmakerAPI_Client.DeserializeUserData(MatchmakerAPI_Client.GetUserData(User.email));
            Page     userProfile = new UserProfile(user, true, LoggedInUserID);

            NavigationService.Navigate(userProfile);
        }
Beispiel #30
0
        //Save button
        private async void btnSave_Click(object sender1, RoutedEventArgs e)
        {
            object image = ImageList.SelectedItem;

            if (image == null)
            {
                //If no image is selected, show a message
                MessageBox.Show("Please select a cover image!", "");
            }
            else
            {
                //Set the selected image as the user's cover image
                MatchMakerClassLibrary.CoverImageData coverImageData = new MatchMakerClassLibrary.CoverImageData();
                coverImageData.userID    = userID;
                coverImageData.imageName = (image as Img).Src.Key;

                ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

                if (await MatchmakerAPI_Client.PostNewCoverImageDataAsync(coverImageData))
                {
                    MessageBox.Show("Image saved!", "");
                }
            }
        }