// PUT api/TitleApi/5 public async Task<IHttpActionResult> PutTitle(int id, Title title) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != title.TitleId) { return BadRequest(); } db.Entry(title).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TitleExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostTitle(Title title) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Title.Add(title); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = title.TitleId }, title); }