public IActionResult Timetable(string stopName, string routeShortName, int directionId, DateTime date) { if (stopName == null || stopName == "" || routeShortName == null || routeShortName == "") { return(View(new StopTimetable() { RequestedDate = date == DateTime.MinValue ? DateTime.Now : date })); } var gtfsline = _context.Gtfslines.FirstOrDefault(x => x.TripShortName == routeShortName); StopTimetable timetable = new StopTimetable() { StopName = stopName, DirectionId = directionId, TripShortName = routeShortName, RouteShortName = gtfsline.Code, HTMLColor = gtfsline.Htmlcolor, RouteStopLocations = _context.LocationsForRouteStops(routeShortName, directionId, date), StopLocation = _context.StopLocation(stopName, directionId), RequestedDate = date == DateTime.MinValue ? DateTime.Now : date, }; timetable.StopTimetables = _context.StopTimesForStop(stopName, routeShortName, directionId, timetable.RequestedDate); return(View(timetable)); }
public async Task <IActionResult> Index(string stopName, int directionId, DateTime date) { if (stopName == null || stopName == "") { return(View(new StopTimetable() { RequestedDate = date == DateTime.MinValue ? DateTime.Now : date })); } StopTimetable timetable = new StopTimetable() { StopName = stopName, DirectionId = directionId, StopLocation = _context.StopLocation(stopName, directionId), RequestedDate = date == DateTime.MinValue ? DateTime.Now : date, }; if (User.Identity.IsAuthenticated) { ApplicationUser user = await _userManager.GetUserAsync(HttpContext.User); timetable.StopTimetables = _context.StopTimesForStopLoggedIn(stopName, directionId, user.Id, timetable.RequestedDate); return(View(timetable)); } timetable.StopTimetables = _context.StopTimesForStop(stopName, directionId, timetable.RequestedDate); return(View(timetable)); }