예제 #1
0
        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;
        }
예제 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            StopTimes stopTimes = db.StopTimes.Find(id);

            db.StopTimes.Remove(stopTimes);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #3
0
        public ActionResult Edit([Bind(Include = "id,trip_id,arrival_time,departure_time,stop_id,stop_sequence")] StopTimes stopTimes)
        {
            if (ModelState.IsValid)
            {
                //stopTimes.pickup_type = 0;
                //stopTimes.drop_off_type = 0;

                db.Entry(stopTimes).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(stopTimes));
        }
예제 #4
0
        // GET: StopTime/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StopTimes stopTimes = db.StopTimes.Find(id);

            if (stopTimes == null)
            {
                return(HttpNotFound());
            }
            return(View(stopTimes));
        }
예제 #5
0
        public ActionResult Create([Bind(Include = "id,trip_id,arrival_time,departure_time,stop_id,stop_sequence")] StopTimes stopTimes)
        {
            if (ModelState.IsValid)
            {
                stopTimes.pickup_type   = 0;
                stopTimes.drop_off_type = 0;

                db.StopTimes.Add(stopTimes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stopTimes));
        }
예제 #6
0
 public void Accept(IFeedVisitor visitor)
 {
     Agencies.Accept(visitor);
     Stops.Accept(visitor);
     Routes.Accept(visitor);
     Trips.Accept(visitor);
     StopTimes.Accept(visitor);
     Calendars.Accept(visitor);
     CalendarDates.Accept(visitor);
     FareAttributes.Accept(visitor);
     FareRules.Accept(visitor);
     Shapes.Accept(visitor);
     Frequencies.Accept(visitor);
     Transfers.Accept(visitor);
     FeedInfos.Accept(visitor);
 }
예제 #7
0
 public void Accept(IFeedVisitor visitor)
 {
     Parallel.Invoke(
         () => Agencies.Accept(visitor),
         () => Stops.Accept(visitor),
         () => Routes.Accept(visitor),
         () => Trips.Accept(visitor),
         () => StopTimes.Accept(visitor),
         () => Calendars.Accept(visitor),
         () => CalendarDates.Accept(visitor),
         () => FareAttributes.Accept(visitor),
         () => FareRules.Accept(visitor),
         () => Shapes.Accept(visitor),
         () => Frequencies.Accept(visitor),
         () => Transfers.Accept(visitor),
         () => FeedInfos.Accept(visitor)
         );
 }
예제 #8
0
        private void PopulateData(Response <StopTime> callbackData)
        {
            List <StopTime> content = callbackData.content;

            HasMore = callbackData.hasMore;
            TripsCache.Instance.GetTrips(
                content.Select((stopTime) => { return(stopTime.tripId); }),
                () =>
            {
                foreach (StopTime stopTime in content)
                {
                    StopTimes.Add(
                        new StopTimeViewModel(stopTime, TripsCache.Instance.Get(stopTime.tripId))
                        );
                }
                ShowMoreButton = true;
                page++;
            }
                );
        }
예제 #9
0
        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);
        }