public ActionResult Search(FriendsViewModel model)
        {
            var users = userService.Search( model.Users.Settings, model.Search);
            var searched = Mapper.Map<IEnumerable<ProfileViewModel>>(users);

            var me = userService.GetUserByEmail(User.Identity.Name);
            var friends = userService.GetFriends(me.UserId).ToList();
            friends.Add(me);

            foreach (var s in searched)
                for (int i = 0; i < friends.Count; i++)
                    if (friends[i].UserId == s.UserId)
                    {
                        s.IsFriend = true;
                        friends.Remove(friends[i]);
                        break;
                    }

            var viewModel = new FriendsViewModel()
            {
                Users = new PagedCollection<ProfileViewModel>()
                {
                   Entities = searched,
                   Settings = users.Settings
                },
                IsFriends = false
            };
            ViewBag.Title = "Search";

            return View("Friends", viewModel);
        }
        public ActionResult Friends(FriendsViewModel model)
        {
            User user;
            user = userService.GetUser(model.id);
            if (user == null)
                user = userService.GetUserByEmail(User.Identity.Name);
            var friends = userService.GetFriends(user.UserId, model.Users.Settings);
            var mapped = Mapper.Map<IEnumerable<ProfileViewModel>>(friends.Entities);
            
            var viewModel = new FriendsViewModel()
            {
                Users = new PagedCollection<ProfileViewModel>()
                {
                    Entities = mapped,
                    Settings = friends.Settings,                   
                },
                IsFriends = true,
                id = model.id,
            };
            return View(viewModel);

        }