示例#1
0
 public void AddUser(user user)
 {
     lock (_lock)
     {
         _userRepository.Insert(user);
         Commit();
     }
 }
示例#2
0
 public void AddFriend(user user, user newFriend)
 {
     lock(_lock)
     {
         _friendsRepository.Insert(new friends { F_ID = newFriend.ID, U_ID = user.ID });
         Commit();
     }
 }
示例#3
0
 public void DeleteUser(user user)
 {
     // We don't have to implicitly delete all the friends of this user because
     // (delete) dissemination is enabled on the MySql-Server. (ON DELETE/UPDATE CASCADE in the foreign key options)
     lock (_lock)
     {
         _userRepository.Delete(user);
         Commit();
     }
 }
示例#4
0
        public IList<user> GetFriends(user user)
        {
            lock (_lock)
            {
                IQueryable<int> friendIds = from f in _friendsRepository.Table
                                            where f.U_ID == user.ID
                                            select f.F_ID;

                IQueryable<user> friends = from u in _userRepository.Table
                                           from friendId in friendIds
                                           where u.ID == friendId
                                           select u;

                return friends.ToList(); // Execute query
            }
        }
示例#5
0
 public void UpdateUser(user user)
 {
     lock (_lock)
     {
         _userRepository.Update(user);
         Commit();
     }
 }
示例#6
0
 public void RemoveFriend(user user, user friendToRemove)
 {
     lock (_lock)
     {
         _friendsRepository.Delete(new friends { U_ID = user.ID, F_ID = friendToRemove.ID });
         Commit();
     }
 }