public IEnumerable <TravelPlan> GetTravelPlans(TravelOptions travelOptions) { var source = travelOptions.Source; var destination = travelOptions.Destination; ValidateLocations(source, destination); var startDate = travelOptions.StartDate ?? DateTime.Now; var graph = _graphBuilder.GetGraph(startDate); // Get the names of the closest stops by location coordinates if (string.IsNullOrEmpty(source.Name) || string.IsNullOrEmpty(destination.Name)) { UpdatedLocationsWithNamesOfTheClosestStops(source, destination, graph); } // Get available paths from source to destination var availablePaths = _pathProvider.GetAvailablePaths(graph, source, destination); availablePaths.ForEach(p => p.StartDate = startDate); var travelPlans = _mapper.Map <List <TravelPlan> >(availablePaths); var travelPlanId = 1; travelPlans?.ForEach(t => { t.Id = travelPlanId; travelPlanId++; }); return(travelPlans?.OrderBy(t => t.Transfers).ThenBy(t => t.StartTime).ThenBy(t => t.Duration)); }