//Gets the route allocation details using a lamda query. public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } RouteAllocation = _context.RouteAllocation .Include(r => r.Bus) .Include(r => r.Driver) .Include(r => r.Route).FirstOrDefault(m => m.Id == id); if (RouteAllocation == null) { return(NotFound()); } return(Page()); }
//Deletes a route allocation uses a linq query to get the route allocation. public IActionResult OnPost(int?id) { if (id == null) { return(NotFound()); } RouteAllocation = (from routeAllocation in _context.RouteAllocation where routeAllocation.Id == id select routeAllocation).FirstOrDefault(); if (RouteAllocation != null) { _context.RouteAllocation.Remove(RouteAllocation); _context.SaveChanges(); } return(RedirectToPage("./Index")); }
//Gets the route allocation for update. public IActionResult OnGet(int?id) { if (id == null) { return(NotFound()); } RouteAllocation = _context.RouteAllocation .Include(r => r.Bus) .Include(r => r.Driver) .Include(r => r.Route).FirstOrDefault(m => m.Id == id); if (RouteAllocation == null) { return(NotFound()); } ViewData["BusId"] = new SelectList(_context.Bus, "Id", "BusNumber"); ViewData["DriverId"] = new SelectList(_context.Driver, "Id", "Name"); ViewData["RouteId"] = new SelectList(_context.Set <Route>(), "Id", "Name"); return(Page()); }