// GET: Znajomi
        public ActionResult Index()
        {
            ProjektEntities db     = new ProjektEntities();
            var             friend = from i in db.FRIENDS
                                     where i.User_ID == User.Identity.Name
                                     join us in db.USER
                                     on i.Friend_ID equals us.User_ID
                                     where us.Is_Exists == true
                                     select new { us.User_ID, us.Image };

            var mod = new FriendsListView
            {
                ListFriends = new List <FriendsView>(),
                ListSearch  = new List <FriendsView>()
            };

            foreach (var x in friend)
            {
                mod.ListFriends.Add(new FriendsView {
                    UserID = x.User_ID, imageData = x.Image
                });
            }

            return(View(mod));
        }
Exemple #2
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     FriendsListView.BeginRefresh();
     VM.InitialUser();
     FriendsListView.EndRefresh();
 }
Exemple #3
0
        private void FriendsSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            IsFromCode = true;
            var textbox = ((TextBox)sender);

            if (textbox.FocusState == FocusState.Unfocused)
            {
                return;
            }
            if (textbox.Text.Replace(" ", "") == "")
            {
                if (FriendsGroupedByKey.Source != friendsByKeyDefault)
                {
                    FriendsGroupedByKey.Source = friendsByKeyDefault;
                    foreach (var item in selectedUsers)
                    {
                        var firstIndex = FriendsListView.Items.IndexOf(item);
                        var indexRange = new Windows.UI.Xaml.Data.ItemIndexRange(firstIndex, 1);
                        try
                        {
                            FriendsListView.SelectRange(indexRange);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            else
            {
                var searchResult = new ObservableCollection <FriendsGroupByKey>();
                var validFriends = friendsByKeyDefault?.SelectMany(group => group.ToArray())?.Where(friend => IsUserSearchResult(textbox.Text, friend.User) || selectedUsers.IndexOf(friend) != -1);
                searchResult = GroupFriendsByKey(validFriends);
                FriendsGroupedByKey.Source = searchResult;
                var results = searchResult?.SelectMany(x => x.ToList())?.ToList();
                foreach (var item in selectedUsers)
                {
                    if (results != null && results.IndexOf(item) != -1)
                    {
                        var firstIndex = FriendsListView.Items.IndexOf(item);
                        var indexRange = new Windows.UI.Xaml.Data.ItemIndexRange(firstIndex, 1);
                        try
                        {
                            FriendsListView.SelectRange(indexRange);
                        }
                        catch
                        {
                        }
                    }
                }
            }
            IsFromCode = false;
        }
        public ActionResult Zapros(string userID)
        {
            var db     = new ProjektEntities();
            var friend = from i in db.FRIENDS
                         where i.User_ID == User.Identity.Name
                         join us in db.USER
                         on i.Friend_ID equals us.User_ID
                         where us.Is_Exists == true
                         select new { us.User_ID, us.Image };

            var mod = new FriendsListView
            {
                ListFriends = new List <FriendsView>(),
                ListSearch  = new List <FriendsView>()
            };

            foreach (var x in friend)
            {
                mod.ListFriends.Add(new FriendsView {
                    UserID = x.User_ID, imageData = x.Image
                });
            }

            USER user = db.USER.Find(userID);


            /*  INVITATIONS invitation = new INVITATIONS();
             * invitation.Accept = false;
             * invitation.From_ID = User.Identity.Name;
             * invitation.To_ID = userID;
             * db.INVITATIONS.Add(invitation);*/

            FRIENDS newFriend = new FRIENDS();

            newFriend.Friend_ID = userID;
            newFriend.User_ID   = User.Identity.Name;
            db.FRIENDS.Add(newFriend);
            db.SaveChanges();
            newFriend.User_ID   = userID;
            newFriend.Friend_ID = User.Identity.Name;
            db.FRIENDS.Add(newFriend);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Index(FriendsListView friendsListView)
        {
            ProjektEntities db     = new ProjektEntities();
            var             friend = from i in db.FRIENDS
                                     where i.User_ID == User.Identity.Name
                                     join us in db.USER
                                     on i.Friend_ID equals us.User_ID
                                     where us.Is_Exists == true
                                     select new { us.User_ID, us.Image };

            var mod = new FriendsListView
            {
                ListFriends = new List <FriendsView>(),
                ListSearch  = new List <FriendsView>()
            };

            foreach (var x in friend)
            {
                mod.ListFriends.Add(new FriendsView {
                    UserID = x.User_ID, imageData = x.Image
                });
            }

            string a = Request["pole"];

            if (a != string.Empty)
            {
                var search = from us in db.USER
                             where us.User_ID.Contains(a) && us.Is_Exists == true && us.User_ID != User.Identity.Name
                             orderby us.User_ID
                             select new { us.User_ID, us.Image };

                foreach (var x in search)
                {
                    System.Diagnostics.Debug.WriteLine("imie " + x.User_ID + " wpis " + a);
                    mod.ListSearch.Add(new FriendsView {
                        UserID = x.User_ID, imageData = x.Image
                    });
                }
            }

            return(View(mod));
        }
Exemple #6
0
        protected override async void OnAppearing()
        {
            UserSearchBar.IsEnabled = false;
            FriendsListView.BeginRefresh();
            var Temp = await VM.OnAppearing();

            if (Temp.Count != 0)
            {
                ListVisble();
                FriendsListView.ItemsSource = Temp;
            }
            else
            {
                ResultLbl.Text = "Friend list is empty.";
                ResultLblVisibleOnly();
            }
            UserSearchBar.IsEnabled = true;
            FriendsListView.EndRefresh();
        }
Exemple #7
0
        private async void FriendsListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (ClickedBtn == true)
            {
                FriendsListView.BeginRefresh();
                await VM.AddFriendToFriendsListAsync((User)e.Item);

                FriendsListView.EndRefresh();
                RefreshList();
                ClickedBtn = false;
            }
            else
            {
                FriendsListView.BeginRefresh();
                await VM.SearchIndividualChatRoom((User)e.Item);

                FriendsListView.EndRefresh();
            }
        }
Exemple #8
0
        private void UserSearchBar_TextChanged(object sender, TextChangedEventArgs e)
        {
            string InputEmail = e.NewTextValue;

            FriendsListView.BeginRefresh();
            if (InputEmail != UserSetting.UserEmail)
            {
                if (!string.IsNullOrWhiteSpace(InputEmail))
                {
                    if (CountData(e.NewTextValue) != 0)
                    {
                        ListVisble();
                        FriendsListView.ItemsSource = VM.FriendsList.Where(i => i.Email.ToLower().Contains(InputEmail.ToLower()));
                    }
                    else
                    {
                        ListInvisible();
                        ResultLbl.Text     = "User not in your friends list.";
                        SearchUserBtn.Text = "Search New User \"" + InputEmail + "\"";
                    }
                }
                else
                {
                    if (VM.FriendsList.Count != 0)
                    {
                        ListVisble();
                        FriendsListView.ItemsSource = VM.FriendsList;
                    }
                    else
                    {
                        ResultLbl.Text = "Friend list is empty.";
                        ResultLblVisibleOnly();
                    }
                }
            }
            else
            {
                ResultLblVisibleOnly();
                ResultLbl.Text = "Hi," + UserSetting.UserName;
            }
            FriendsListView.EndRefresh();
        }
Exemple #9
0
 private void SelectAllButton_Click(object sender, RoutedEventArgs e)
 {
     FriendsListView.SelectAll();
 }