public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Datum).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DatumExists(Datum.id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Datum.Add(Datum); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Datum = await _context.Datum.FindAsync(id); if (Datum != null) { _context.Datum.Remove(Datum); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// Delete the selected item from the database public async Task DeleteData(int id) { _context.Datum.Remove(_context.Datum.Find(id)); await _context.SaveChangesAsync(); }