public async Task<IHttpActionResult> PutAnnotatedWord(int id, AnnotatedWord annotatedWord) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != annotatedWord.Id) { return BadRequest(); } db.Entry(annotatedWord).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnnotatedWordExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public async Task<IHttpActionResult> PostAnnotatedWord(AnnotatedWord annotatedWord) { if (!ModelState.IsValid) { return BadRequest(ModelState); } annotatedWord.Sentiment = 0.0; db.AnnotatedWords.Add(annotatedWord); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = annotatedWord.Id }, annotatedWord); }