public void Load(TrackTrackerRepository repository) { if (Loaded) { return; } if (Trip == null) { Trip = repository.TripsCache.First(x => x.TripId == TripId); TripHeadsign = Trip.TripHeadsign; } if (StopTimes == null) { StopTimes = repository.GetTripStopTimes(Trip).OrderBy(x => x.ArrivalTime).Select(x => new StopTimeMinified { ArrivalTimeRaw = x.ArrivalTimeRaw, DepartureTimeRaw = x.DepartureTimeRaw, StopId = x.StopId, ShapeDistanceTraveled = x.ShapeDistTraveled.Value }).ToList(); } TripShapes = repository.GetTripShapes(Trip).ToList(); Stops = StopTimes.Select(x => repository.StopsCache.First(s => s.StopId == x.StopId)).ToList(); Loaded = true; }
public TripDetails(TrackTrackerRepository repository, Trip trip) { TripId = trip.TripId; RouteId = trip.RouteId; ShapeId = trip.ShapeId; ServiceId = trip.ServiceId; Route = repository.GetTripRoute(trip); Service = repository.CalendarsCache.First(x => x.ServiceId == trip.ServiceId); TripHeadsign = trip.TripHeadsign; DirectionId = trip.DirectionId; }
public void LoadAsync(TrackTrackerRepository repository) { if (!LoadingTask) { LoadingTask = true; Task.Factory.StartNew(() => { lock (repository) { Load(repository); } }); } }
public bool IsTrainRunning(DateTime currentTime, TrackTrackerRepository repository) { var firstStopTime = StopTimes.FirstOrDefault(); var lastStopTime = StopTimes.LastOrDefault(); if (firstStopTime == null || lastStopTime == null) { TrainRunning = false; return(false); } // ReSharper disable PossibleInvalidOperationException if (firstStopTime.DepartureTime.TimeOfDay < currentTime.TimeOfDay && lastStopTime.ArrivalTime.TimeOfDay > currentTime.TimeOfDay) { TrainRunning = true; return(repository.IsTripRunning(Trip, currentTime)); } TrainRunning = false; return(false); }