public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } InvoiceModel = await _context.InvoiceTable.FindAsync(id); if (InvoiceModel != null) { _context.InvoiceTable.Remove(InvoiceModel); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (!ModelState.IsValid) { return(Page()); } if (id == null) { return(RedirectToPage("./Index")); } if (InvoiceModel == null) { return(NotFound()); } InvoiceModel.ID = (int)id; _context.InvoiceTable.Update(InvoiceModel); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }