private FriendsViewModel GetFriends(int page=1)
        {
            var currentUser = manager.FindById(User.Identity.GetUserId());

            var friendsId = currentUser.Friends
                           .Select(x => x.FriendId);

            var friends = repository.ApplicationUsers
                                .Where(u => friendsId.Contains(u.Id))
                                .OrderBy(u => u.Id)
                                .Skip((page - 1) * FriendsPerPage)
                                .Take(FriendsPerPage);

            var model = new FriendsViewModel
            {
                Friends = friends,
                PagingInfo = new PagingInfo
                {
                    TotalPages = (int)Math.Ceiling((decimal)friendsId.Count() / FriendsPerPage),
                    TotalItems = friendsId.Count(),
                }
            };
            TempData["InfoMessage"] = currentUser.FirstName+"'s "+"Friends" + " - " + model.PagingInfo.TotalItems;

            return model;
        }
        private FriendsViewModel GetConversations(int page = 1)
        {
            var currentUser = manager.FindById(User.Identity.GetUserId());

            var conversbySend = repository.UserMessages
                           .Where(m => m.SenderId == currentUser.Id)
                           .Select(x => x.ReceiverId)
                           .ToList();

            var conversbyReceiv = repository.UserMessages
                             .Where(m => m.ReceiverId == currentUser.Id)
                             .Select(x => x.SenderId);

            conversbySend.AddRange(conversbyReceiv);

            var conversations = repository.ApplicationUsers
                               .Where(u => conversbySend.Contains(u.Id))
                               .OrderBy(u => u.Id)
                               .Skip((page - 1) * ConversationsPerPage)
                               .Take(ConversationsPerPage);

            var count = repository.ApplicationUsers
                               .Where(u => conversbySend.Contains(u.Id)).Count();

            var model = new FriendsViewModel
            {
                Friends = conversations,
                PagingInfo = new PagingInfo
                {
                    TotalPages = (int)Math.Ceiling((decimal)count / ConversationsPerPage),
                    TotalItems = count,
                }

            };
            TempData["InfoMessage"] = "Conversations" + " - " + model.PagingInfo.TotalItems;

            return model;
        }
        //GET: DisplayUsers
        public ActionResult DisplayUsers(SearchViewModel model,int page=1)
        {
            var users = repository.ApplicationUsers;
            var currentUser = manager.FindById(User.Identity.GetUserId());

            var adminsId = repository.UserRoles.Select(x => x.UserId);
            var admins = repository.ApplicationUsers.Where(u => adminsId.Contains(u.Id)).Select(u => u);
            users = users.Except(admins);

            if (model.FirstName != null)
                users = users.Where(u => u.FirstName == model.FirstName);

            if (model.LastName != null)
                users = users.Where(u => u.LastName == model.LastName);

            if (model.Age != null)
                users = users.Where(u => u.Age == model.Age);

            if (model.Country != null)
                users = users.Where(u => u.Country == model.Country);

            if (model.City != null)
                users = users.Where(u => u.City == model.City);

            if (users.Count() == 0)
                TempData["InfoMessage"] = "No user for this search";

            var foundUsers = new FriendsViewModel
            {
                Friends = users.OrderBy(u=>u.Id).Skip((page - 1) * UsersPerPage)
                .Take(UsersPerPage),

                PagingInfo = new PagingInfo
                {
                    TotalItems = users.Count(),
                    ItemsPerPage = UsersPerPage,
                    CurrentPage = page,
                }
            };

            return View(foundUsers);
        }