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