public List<Trip> GetTripsByUser(User.User user) { List<Trip> tripList = new List<Trip>(); User.User loggedUser = UserSession.GetInstance().GetLoggedUser(); bool isFriend = false; if (loggedUser != null) { foreach(User.User friend in user.GetFriends()) { if (friend.Equals(loggedUser)) { isFriend = true; break; } } if (isFriend) { tripList = TripDAO.FindTripsByUser(user); } return tripList; } else { throw new UserNotLoggedInException(); } }
private List<Trip> FindtripsByFriendsOf(User.User user, User.User loggedUser) { foreach(User.User friend in user.GetFriends()) { if (friend.Equals(loggedUser)) { return tripDao.FindTripsByUser(user); } } return NoTrips (); }