public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Vehicle).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VehicleExists(Vehicle.ID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Vehicle.Add(Vehicle); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Vehicle = await _context.Vehicle.FindAsync(id); if (Vehicle != null) { _context.Vehicle.Remove(Vehicle); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }