Exemplo n.º 1
0
        public ActionResult Index(string keyword)
        {
            bool flag = false;

            _viewModel = new FriendSectionViewModel();
            CreateLayoutView("Tìm kiếm bạn bè");
            if (keyword != null)
            {
                List <String> listUser   = _applicationUserService.FindFriend(keyword);
                List <Friend> listFriend = _friendService.GetAllFriends(User.Identity.GetUserId());
                foreach (String user in listUser)
                {
                    FriendViewModel friendViewModel = new FriendViewModel();
                    ApplicationUser userT           = _service.GetUserById(user);
                    FieldHelper.CopyNotNullValue(friendViewModel, userT);
                    if (flag == false)
                    {
                        foreach (Friend friend in listFriend)
                        {
                            if (friend.Id_Friend == user || friend.Id_User == user)
                            {
                                friendViewModel.FriendDate = friend.UpdatedDate;
                            }
                            flag = true;
                        }
                    }
                    FriendSectionViewModel.ListFriend.Add(friendViewModel);
                }
            }
            return(View(FriendSectionViewModel));
        }