private static void ProcessData(string jsonVehicles) { var dataVehicles = JsonConvert.DeserializeObject <dynamic>(jsonVehicles).data; foreach (var vehicle in dataVehicles) { // only concerned with vehicles currently at stations if (vehicle.attributes.current_status == "STOPPED_AT") { string tripID = vehicle.relationships.trip.data.id; // get this vehicle's trip (if it doesn't exist, ignore it) Trip curTrip = Today.Trips.SingleOrDefault(x => x.TripID == tripID); if (curTrip != null) { string gtfs = vehicle.relationships.stop.data.id; string placeID = Utils.ResolveGTFS(gtfs); // get this vehicle's stop (if it doesn't exist, ignore it) // also make sure it has an arrival time (if not, ignore it) Stop curStop = curTrip.Stops.SingleOrDefault(x => x.PlaceID == placeID); if (curStop != null && curStop.Arrival != 0) { // complete it only if it has not already been completed (delta is null) // otherwise, continue completion (update departure time) if (curStop.Delta == null) { curStop.Complete(); } else { curStop.ContinueCompletion(); } } } } } }