public IHttpActionResult PutBranchBook(int id, BranchBook branchBook) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != branchBook.ID) { return BadRequest(); } db.Entry(branchBook).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BranchBookExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostBranchBook(BranchBook branchBook) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.BranchBooks.Add(branchBook); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = branchBook.ID }, branchBook); }