Esempio n. 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (CurrentUser.Age == -1)
            {
                NavigationService.Navigate(new Uri("/FillMeetForm.xaml", UriKind.Relative));
            }

            User userSelected = null;

            if (PhoneApplicationService.Current.State.Keys.Contains("param"))
            {
                userSelected = (User)PhoneApplicationService.Current.State["param"];
            }

            if (PhoneApplicationService.Current.State.Keys.Contains("connections"))
            {
                ListConnections = (List <Connection>)PhoneApplicationService.Current.State["connections"];
            }

            User tmp = ListPhonesConnected.Where(x => x.Username == userSelected.Username).FirstOrDefault();

            if (tmp != null)
            {
                tmp = userSelected;
            }

            base.OnNavigatedTo(e);
        }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            List <User> listMatchedUsers = new List <User>();

            foreach (Connection connect in ListConnections)
            {
                if (connect.ConnectedFrom == CurrentUser.Username)
                {
                    foreach (Connection connect1 in ListConnections)
                    {
                        if (connect1 != connect && connect1.ConnectedFrom == connect.ConnectedTo && connect1.ConnectedTo == CurrentUser.Username)
                        {
                            User tmpUser = ListPhonesConnected.Where(x => x.Username == connect1.ConnectedFrom).FirstOrDefault();
                            if (tmpUser != null)
                            {
                                if (listMatchedUsers.Where(x => x.Username == tmpUser.Username).FirstOrDefault() == null)
                                {
                                    listMatchedUsers.Add(tmpUser);
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (connect.ConnectedTo == CurrentUser.Username)
                {
                    foreach (Connection connect1 in ListConnections)
                    {
                        if (connect1 != connect && connect1.ConnectedTo == connect.ConnectedFrom && connect1.ConnectedFrom == CurrentUser.Username)
                        {
                            User tmpUser = ListPhonesConnected.Where(x => x.Username == connect1.ConnectedTo).FirstOrDefault();
                            if (tmpUser != null)
                            {
                                if (listMatchedUsers.Where(x => x.Username == tmpUser.Username).FirstOrDefault() == null)
                                {
                                    listMatchedUsers.Add(tmpUser);
                                    break;
                                }
                            }
                        }
                    }
                }
            }


            //foreach (Connection connection in ListConnections)
            //{
            //    if (connection.ConnectedFrom == CurrentUser.Username)
            //    {
            //        User tempUser = ListPhonesConnected.Where(x => x.Username == connection.ConnectedTo).FirstOrDefault();
            //        if (tempUser != null)
            //        {
            //            foreach (Connection connection1 in ListConnections)
            //            {
            //                if (connection1.ConnectedFrom == tempUser.Username)
            //                {
            //                    listMatchedUsers.Add(tempUser);
            //                    break;
            //                }
            //            }
            //        }
            //    }
            //    else if (connection.ConnectedTo == CurrentUser.Username)
            //    {
            //        User tempUser = ListPhonesConnected.Where(x => x.Username == connection.ConnectedFrom).FirstOrDefault();
            //        if (tempUser != null)
            //        {
            //            foreach (Connection connection1 in ListConnections)
            //            {
            //                if (connection1.ConnectedFrom == tempUser.Username)
            //                {
            //                    listMatchedUsers.Add(tempUser);
            //                    break;
            //                }
            //            }
            //        }
            //    }
            //}

            PhoneApplicationService.Current.State["connections"]  = ListConnections;
            PhoneApplicationService.Current.State["MacthedUsers"] = listMatchedUsers;
            NavigationService.Navigate(new Uri("/MutualConnections.xaml", UriKind.Relative));
        }