/* Action for clicking the schedule tab on the navigation bar shared between all views */ public async System.Threading.Tasks.Task <IActionResult> ScheduleAsync() { DateTime now = DateTime.Now; try { string email = HttpContext.Session.GetString("username"); Task <IEnumerable <IFlight> > allFlights; if (HttpContext.Session.GetInt32("isAdmin") == 1) { email = ""; allFlights = _db_flights.GetAll(now); } else { allFlights = _db_flights.GetAll(now, "VR-140", email); } ViewBag.dateSelected = now; ViewBag.email = email; ViewBag.Flights = await allFlights; ViewBag.PilotList = await PilotListGenerator.GetPilotEmailsAsync(_db_pilots); ViewBag.RouteList = await RouteListGenerator.GenerateRouteListAsync("VR-140", _db_route); ViewBag.RouteListRaw = await _db_route.GetAll(); ViewBag.RouteSelected = "VR-140"; return(View()); } catch (ArgumentNullException) { /*Dillon & Luke do something here*/ } return(Content("Todo 4")); }
/* Action for clicking the 'Update' button on the schedule view. This updates the schedule view, showing the flights pertaining only * to the date selected. */ public async System.Threading.Tasks.Task <IActionResult> UpdateScheduleViewFlightsAsync(DateTime currentDate, string Route, string email, bool scheduleFailed = false) { try { if (email == null) { email = HttpContext.Session.GetString("username"); } var allFlights = _db_flights.GetAll(currentDate, Route, email); ViewBag.email = email; ViewBag.dateSelected = currentDate; if (scheduleFailed) { ViewBag.scheduleStatus = "fail"; } else { ViewBag.scheduleStatus = "success"; } ViewBag.Flights = await allFlights; ViewBag.PilotList = await PilotListGenerator.GetPilotEmailsAsync(_db_pilots); ViewBag.RouteList = await RouteListGenerator.GenerateRouteListAsync(Route, _db_route); ViewBag.RouteListRaw = await _db_route.GetAll(); ViewBag.RouteSelected = Route; return(View("../Schedule/Schedule")); } catch (ArgumentNullException) { /*Luke & Dillon Do something*/ } return(Content("Todo 3")); }
private async System.Threading.Tasks.Task SetViewBagAsync(string email) { var getAllFlights = _db_flights.GetAll(email); ViewBag.dateSelected = DateTime.Now; ViewBag.email = email; ViewBag.Flights = await getAllFlights; ViewBag.PilotList = await PilotListGenerator.GetPilotEmailsAsync(_db_pilot); ViewBag.RouteList = await RouteListGenerator.GenerateRouteListAsync("VR-140", _db_route); }