Exemplo n.º 1
0
 public void AddFriend(string user, string newFriend)
 {
     using (TempDBFriendListContext db = new TempDBFriendListContext())
     {
         db.Friends.Add(new Friend() { User = user, Friend1 = newFriend });
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public IEnumerable<string> GetFriends(User user)
 {
     IEnumerable<string> friends = null;
     using (TempDBFriendListContext db = new TempDBFriendListContext())
     {
         IEnumerable<string> temp = db.Friends.Where(x => x.User.Equals(user.UserName)).Select(x => x.Friend1).ToList();
         IEnumerable<string> temp2 = db.Friends.Where(x => x.Friend1.Equals(user.UserName)).Select(x => x.User).ToList();
         friends = temp.Union(temp2).ToList();
     }
     return friends;
 }
Exemplo n.º 3
0
 public void RemoveFriend(string user, string friend)
 {
     using (TempDBFriendListContext db = new TempDBFriendListContext())
     {
         db.Friends.Remove(new Friend() { User = user, Friend1 = friend });
         db.SaveChanges();
     }
 }