public ActionResult TripPlanning() { var model = new TripPlanningViewModel(); if (Request.IsAuthenticated) { // find all trips for the user List <BlViewTrip> _allTrips = null; var blError = TripManager.GetAllTripsForUser(User.Identity.GetUserId(), out _allTrips); model.AllTrips = _allTrips; // find any active trip - to move to a business layer method var _activeTrip = _allTrips.FirstOrDefault(p => (p.DlTripView.Status.Trim() == TripStatus.booked.ToString())); // if there IS an active trip - redirect to view if (_activeTrip != null) { var _tripViewModel = new TripViewModel() { ActiveTrip = _activeTrip }; return(View("Trip", _tripViewModel)); } // else show all the planned trips var _plannedTrips = _allTrips.Where(p => (p.DlTripView.Status.Trim() == TripStatus.planned.ToString() || p.DlTripView.Status.Trim() == TripStatus.consulting.ToString())).ToList(); model.PlannedTrips = _plannedTrips; List <Destination> _destinations = null; blError = DestinationManager.GetTopDestinations("", 8, out _destinations); model.SuggestedDestinations = _destinations; } return(View(model)); }