public async Task<IHttpActionResult> PostAnnotatedTweet(AnnotatedTweet annotatedTweet) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.AnnotatedTweets.Add(annotatedTweet); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (AnnotatedTweetExists(annotatedTweet.Id)) { return Conflict(); } else { throw; } } return CreatedAtRoute("DefaultApi", new { id = annotatedTweet.Id }, annotatedTweet); }
public async Task<IHttpActionResult> PutAnnotatedTweet(int id, AnnotatedTweet annotatedTweet) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != annotatedTweet.Id) { return BadRequest(); } db.Entry(annotatedTweet).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnnotatedTweetExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }