public async Task<IHttpActionResult> PutWord(int id, Word word) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != word.Id) { return BadRequest(); } db.Entry(word).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WordExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostWord(Word word) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Words.Add(word); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = word.Id }, word); }