public ActionResult ViewRoute(string id) { DatabaseInterface db = new DatabaseInterface(); ObjectId newId = new ObjectId(id); Route route = db.GetRouteById(newId); if (route == null) { return Json(new { error = "true" }); } return Json(new { html = RenderPartialViewToString("ViewRouteView", new ViewRouteModel() { Stops = route.Stops, DriverName = route.Driver.Name, Name = route.Name, LicensePlate = route.Bus.LicensePlate, RouteId = route.RouteId.ToString() }) }); }