Beispiel #1
0
        public static List<Friend> GetFriendsByAccountID(Int32 AccountID)
        {
            //List<Friend> aFriend = All().ToList();

            List<Friend> result = new List<Friend>();

            //Get my friends direct relationship
            var friends = (from f in Friend.All()
                           where f.AccountID == AccountID &&
                           f.MyFriendsAccountID != AccountID
                           select f).Distinct();
            result = friends.ToList();

            //Getmy friends indirect relationship
            var friends2 = (from f in Friend.All()
                            where f.MyFriendsAccountID == AccountID &&
                            f.AccountID != AccountID
                            select f).Distinct();

            foreach (var o in friends2)
            {
                Friend friend = new Friend()
                {
                    FriendID = o.FriendID,
                    AccountID = o.MyFriendsAccountID,
                    CreateDate = o.CreateDate,
                    MyFriendsAccountID = o.AccountID,
                    Timestamp = o.Timestamp
                };
                result.Add(friend);
            }
            return result;
        }
Beispiel #2
0
 public static void DeleteFriend(Friend friend)
 {
     Friend.Delete(friend.AccountID);
 }
Beispiel #3
0
 public static void SaveFriend(Friend friend)
 {
     if (friend.FriendID > 0)
     {
         Friend.Update(friend);
     }
     else
     {
         friend.CreateDate = DateTime.Now;
         Friend.Add(friend);
     }
 }