// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Inscriere).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InscriereExists(Inscriere.InscriereID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } var student = await _context.Studenti.FindAsync(id); if (student == null) { return(NotFound()); } try { _context.Studenti.Remove(student); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log.) return(RedirectToAction("./Delete", new { id, saveChangesError = true })); } }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Cursuri.Add(Curs); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
// To protect from overposting attacks, see https://aka.ms/RazorPagesCRUD public async Task <IActionResult> OnPostAsync() { var emptyStudent = new Student(); if (await TryUpdateModelAsync <Student>( emptyStudent, "student", // Prefix for form value. s => s.Nume, s => s.Prenume, s => s.DataInscrierii)) { _context.Studenti.Add(emptyStudent); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Curs = await _context.Cursuri.FindAsync(id); if (Curs != null) { _context.Cursuri.Remove(Curs); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(int id) { var studentToUpdate = await _context.Studenti.FindAsync(id); if (studentToUpdate == null) { return(NotFound()); } if (await TryUpdateModelAsync <Student>( studentToUpdate, "student", s => s.Nume, s => s.Prenume, s => s.DataInscrierii)) { await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } return(Page()); }