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