public async Task<IHttpActionResult> PutAuthor(int id, Author author) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != author.authorID) { return BadRequest(); } db.Entry(author).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AuthorExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAuthor(Author author) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Authors.Add(author); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = author.authorID }, author); }