private void AddRouteDetail(RouteDetail routeDetail, Route route)
        {
            var stops = from stop in db.Stops
                        from routeStop in db.RouteStops
                        orderby routeStop.StopSequence
                        where (routeStop.StopID == stop.ID) && (routeStop.RouteID == route.ID)
                        select stop;

            foreach (var stop in stops)
            {
                // Use arrival times if available
                var stopWithArrivalTime = StopArrivalTime.GetStopSummaryWithArrivalTimes(stop.ID);
                if (stopWithArrivalTime != null)
                {
                    routeDetail.Stops.Add(stopWithArrivalTime);
                }
                else
                {
                    routeDetail.Stops.Add(new StopSummary(stop));
                }
            }

            var shapes = from shape in db.Shapes
                        orderby shape.Sequence
                        where (shape.RouteID == route.ID)
                        select shape;

            foreach (var shape in shapes)
            {
                var coordinate = new Location();
                coordinate.Lat = shape.Lat;
                coordinate.Lon = shape.Lon;
                routeDetail.RoutePath.Add(coordinate);
            }
        }
        private void AddRouteDetail(RouteDetail routeDetail, Route route)
        {
            var stops = from stop in db.Stops
                        from routeStop in db.RouteStops
                        orderby routeStop.StopSequence
                        where (routeStop.StopID == stop.ID) && (routeStop.RouteID == route.ID)
                        select stop;

            foreach (var stop in stops)
            {
                routeDetail.Stops.Add(new StopSummary(stop));
            }

            var shapes = from shape in db.Shapes
                        orderby shape.Sequence
                        where (shape.RouteID == route.ID)
                        select shape;

            foreach (var shape in shapes)
            {
                var coordinate = new Location();
                coordinate.Lat = shape.Lat;
                coordinate.Lon = shape.Lon;
                routeDetail.RoutePath.Add(coordinate);
            }
        }
        public IHttpActionResult GetRoute(int id)
        {
            Route route = db.Routes.Find(id);
            if (route == null)
            {
                return NotFound();
            }

            // Assemble route + Stops + Shape
            var routeDetail = new RouteDetail(route);

            AddRouteDetail(routeDetail, route);

            return Ok(routeDetail);
        }