public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["BookId"] = new SelectList(_context.Book, "Id", "Title"); ViewData["PatronId"] = new SelectList(_context.Patron, "Id", "Name"); return(Page()); } _context.Attach(Reservation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservationExists(Reservation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Book).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(Book.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Patron.Add(Patron); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { ViewData["BookId"] = new SelectList(_context.Book, "Id", "Title"); ViewData["PatronId"] = new SelectList(_context.Patron, "Id", "Name"); return(Page()); } _context.Reservation.Add(Reservation); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Book = await _context.Book.FindAsync(id); if (Book != null) { _context.Book.Remove(Book); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }