protected override object Converter(JToken stops) { var stopInTripData = new StopInTripData() { Day = DateTime.Parse(stops.Path), StopsInTrip = new List <StopInTrip>() }; foreach (var item in stops.Children()) { stopInTripData.LastUpdate = item.Value <DateTime>("lastUpdate"); var stopList = item.Value <JArray>("stopsInTrip"); foreach (var stop in stopList.Children <JObject>()) { var stopInTripToAdd = new StopInTrip() { RouteId = stop.Value <int>("routeId"), TripId = stop.Value <int>("tripId"), StopId = stop.Value <int>("stopId"), StopSequence = stop.Value <int>("stopSequence"), AgencyId = stop.Value <int>("agencyId"), TopologyVersionId = stop.Value <int>("topologyVersionId"), TripActivationDate = stop.Value <DateTime>("tripActivationDate"), StopActivationDate = stop.Value <DateTime>("stopActivationDate") }; stopInTripData.StopsInTrip.Add(stopInTripToAdd); } } return(stopInTripData); }
TripsWithBusStops Map(BusLineData busLine, ExpeditionData expeditionObject, TripData tripData, BusStopData busStopData, StopInTripData stopInTripData) { var tripsWithBusStops = new TripsWithBusStops() { Day = busLine.Day, Trips = new List <Trip>() }; busLine.Routes.ForEach(route => { var tripListByRouteId = tripData.Trips.Where(x => x.RouteId == route.RouteId).ToList(); tripListByRouteId.ForEach(tripByRouteId => { var expedition = expeditionObject.Expeditions .FirstOrDefault(exp => exp.RouteId == tripByRouteId.RouteId && exp.TripId == tripByRouteId.TripId && (exp.StartDate.Date == busLine.Day.Date || exp.StartDate.Date < busLine.Day.Date)); if (expedition == null || expedition.TechnicalTrip) { return; } tripsWithBusStops.Trips.Add( new Trip() { Id = tripByRouteId.Id, TripId = tripByRouteId.TripId, RouteId = tripByRouteId.RouteId, AgencyId = route.AgencyId, BusLineName = route.RouteShortName, MainRoute = expedition.MainRoute, TripHeadsign = tripByRouteId.TripHeadsign, DirectionId = tripByRouteId.DirectionId, Stops = _stopHelper.GetStopList(tripByRouteId, stopInTripData.StopsInTrip.Where(x => x.RouteId == tripByRouteId.RouteId && x.TripId == tripByRouteId.TripId).ToList(), expedition.MainRoute, busStopData.Stops) }); }); }); tripsWithBusStops.Trips = tripsWithBusStops.Trips.OrderBy(x => x.BusLineName).ToList(); return(tripsWithBusStops); }