public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Terminal = await _context.accTerminal.FindAsync(id); if (Terminal != null) { _context.accTerminal.Remove(Terminal); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Terminal = await _context.accTerminal .AsNoTracking() .FirstOrDefaultAsync(m => m.IdTerminal == id); if (Terminal == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Terminal = await _context.accTerminal .Include(c => c.Zone) .FirstOrDefaultAsync(m => m.IdTerminal == id); if (Terminal == null) { return(NotFound()); } PopulateZonesDropDownList(_context, Terminal.idZone); return(Page()); }
// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { var emptyTerminal = new accTerminal(); if (await TryUpdateModelAsync <accTerminal>( emptyTerminal, "terminal", // Prefix for form value. s => s.IdTerminal, s => s.idZone, s => s.Name)) { _context.accTerminal.Add(emptyTerminal); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } // Select DepartmentID if TryUpdateModelAsync fails. PopulateZonesDropDownList(_context, emptyTerminal.idZone); return(Page()); }