public List<Trip> GetTripsByUser(User user) { var tripList = new List<Trip>(); var loggedUser = UserSession.GetInstance().GetLoggedInUser(); var isFriend = false; if (loggedUser != null) { foreach(var friend in user.GetFriends()) { if (friend.Equals(loggedUser)) { isFriend = true; break; } } if (isFriend) { tripList = TripDAO.FindTripsByUser(user); } return tripList; } else { throw new UserNotLoggedInException(); } }
public static List<Trip> FindTripsByUser(User user) { throw new CollaboratorCallException( "TripDAO should not be invoked on an unit test."); }
public void AddFriend(User user) { _friends.Add(user); }