public IHttpActionResult PutBookDetail(int id, BookDetail bookDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != bookDetail.BookDetailsId) { return BadRequest(); } db.Entry(bookDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BookDetailExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostBookDetail(BookDetail bookDetail) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.BookDetails.Add(bookDetail); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = bookDetail.BookDetailsId }, bookDetail); }