public ActionResult Result_Post(string query) { ViewBag.Query = query; WhiskeyLogic mngr = new WhiskeyLogic(); List<Friend> mylist = mngr.FindUser(query, User.Identity.GetUserId()); List<Friend> FriendList = mngr.GetFriends(User.Identity.GetUserId()); foreach (var user in mylist) { foreach (var friend in FriendList) { if (friend.FriendId == user.FriendId) { user.IsFriend = true; } } } return View(mylist); }
// GET: SearchUser public ActionResult Result(string query) { using (ApplicationDbContext dbcontext = new ApplicationDbContext()) { query = query == null ? "" : query; ViewBag.Query = query; WhiskeyLogic mngr = new WhiskeyLogic(); List<Friend> mylist = mngr.FindUser(query, User.Identity.GetUserId()); List<Friend> FriendList = mngr.GetFriends(User.Identity.GetUserId()); foreach (var user in mylist) { foreach (var friend in FriendList) { if (friend.FriendId == user.FriendId) { user.IsFriend = true; } } } return View(mylist); } }
public ActionResult UserProfilePage() { string userId = Request.RawUrl.Split('=').Last(); if(userId == User.Identity.GetUserId()) { return Redirect("~/Home/ProfilePage?User="******"", "", "", "", "", 500000, 1, userId); ViewBag.FriendsTopList = mngr.GetFriendsToplist(userId); ViewBag.Friends = mngr.GetFriends(userId); ViewBag.UserId = userId; ViewBag.Username = mngr.FindUserById(userId); ViewBag.CurrentUserFriends = mngr.GetFriends(User.Identity.GetUserId()); List<Friend> mylist = mngr.FindUser("", User.Identity.GetUserId()); List<Friend> FriendList = mngr.GetFriends(User.Identity.GetUserId()); foreach (var user in mylist) { foreach (var friend in FriendList) { if (friend.FriendId == user.FriendId) { user.IsFriend = true; } } } Friend f = mylist.First(x => x.FriendId == userId); ViewBag.IsFriend = f.IsFriend ? true : false; return View(myList); }