private String SingleRouteDetailJSON(Route route, TrolleyTrackerContext db) { var routeDetailList = new List <RouteDetail>(); // Schedule web page expects array, even for single route var routeDetail = new RouteDetail(route); routeDetail.AddRouteDetail(db, route); routeDetailList.Add(routeDetail); string routeDetailJSON = JsonConvert.SerializeObject(routeDetailList); return(routeDetailJSON); }
private string ActiveRouteDetailJSON(TrolleyTrackerContext db) { var activeRouteSummaries = ActiveRoutes.GetActiveRoutes(); var routeDetailList = new List <RouteDetail>(); foreach (var routeSummary in activeRouteSummaries) { var route = db.Routes.Find(routeSummary.ID); var routeDetail = new RouteDetail(route); routeDetail.AddRouteDetail(db, route); routeDetailList.Add(routeDetail); } string routeDetailJSON = JsonConvert.SerializeObject(routeDetailList); return(routeDetailJSON); }
public IHttpActionResult GetRoute(int id) { using (var db = new TrolleyTracker.Models.TrolleyTrackerContext()) { Route route = db.Routes.Find(id); if (route == null) { return(NotFound()); } // Assemble route + Stops + Shape var routeDetail = new RouteDetail(route); routeDetail.AddRouteDetail(db, route); return(Ok(routeDetail)); } }