public void AddUser(user user) { lock (_lock) { _userRepository.Insert(user); Commit(); } }
public void AddFriend(user user, user newFriend) { lock(_lock) { _friendsRepository.Insert(new friends { F_ID = newFriend.ID, U_ID = user.ID }); Commit(); } }
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(); } }
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 } }
public void UpdateUser(user user) { lock (_lock) { _userRepository.Update(user); Commit(); } }
public void RemoveFriend(user user, user friendToRemove) { lock (_lock) { _friendsRepository.Delete(new friends { U_ID = user.ID, F_ID = friendToRemove.ID }); Commit(); } }