private void PopulateNotFriends() { IDAL DAL = new DBDataAL(); IEnumerable<string> friends = DAL.GetFriends(Owner); IEnumerable<string> users = DAL.GetAllUsernames(); NotFriends = users.Where(x => x != Owner.UserName).Where(x => !friends.Contains(x)).ToList(); }
public ActionResult SortByDefenseAscending(bool isGlobal) { IDAL DAL = new DBDataAL(); Leaderboard board = new Leaderboard(); board.IsGlobal = isGlobal; IEnumerable<User> users; if (isGlobal) { users = DAL.GetAllUsers().OrderBy(x => x.HighDefense); } else { string userName = User.Identity.Name; User currentUser = DAL.GetUser(userName); IEnumerable<string> friends = DAL.GetFriends(currentUser); users = DAL.GetAllUsers().Where(x => friends.Contains(x.UserName)).OrderBy(x => x.HighDefense); } board.Users = users; return View("~/Views/Web/Leaderboard.cshtml", board); }
public ActionResult AcceptFriendRequest(string sender) { string currentUser = User.Identity.Name; IDAL DAL = new DBDataAL(); User user = DAL.GetUser(currentUser); IEnumerable<string> friends = DAL.GetFriends(user).ToList(); if(!friends.Contains(sender)) { DAL.AddFriend(currentUser, sender); } IEnumerable<FriendRequest> requests = DAL.GetFriendRequests(user).Where(r => r.Sender == sender); IEnumerable<FriendRequest> requests2 = DAL.GetFriendRequests(DAL.GetUser(sender)).Where(r => r.Sender == currentUser); IEnumerable<FriendRequest> fullList = requests.Concat(requests2); foreach (FriendRequest req in fullList) { DAL.RemoveFriendRequest(req); } FriendData data = new FriendData(currentUser); return View("~/Views/Web/Friends.cshtml", data); }
private void PopulateFriendsList() { IDAL DAL = new DBDataAL(); FriendsList = DAL.GetFriends(Owner).ToList(); }
public ActionResult SwitchToFriends() { Leaderboard board = new Leaderboard(); board.IsGlobal = false; IDAL DAL = new DBDataAL(); User currentUser = DAL.GetUser(User.Identity.Name); IEnumerable<string> friends = DAL.GetFriends(currentUser); IEnumerable<User> users = DAL.GetAllUsers().Where(x => friends.Contains(x.UserName)); return View("~/Views/Web/Leaderboard.cshtml", board); }