public async Task <IActionResult> PutBook([FromRoute] int id, [FromBody] Book book) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != book.Id) { return(BadRequest()); } _context.Entry(book).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BookExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task AddBook(BookEntity book) { await _context.AddAsync(book); await _context.SaveChangesAsync(); }
public async Task Add(ReservationEntity reservation) { await _context.Reservations.AddAsync(reservation); await _context.SaveChangesAsync(); }