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