public async Task <IHttpActionResult> PostAnnotatedConversation(AnnotatedConversation annotatedConversation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AnnotatedConversations.Add(annotatedConversation); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (AnnotatedConversationExists(annotatedConversation.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = annotatedConversation.Id }, annotatedConversation)); }
public async Task <IHttpActionResult> PutAnnotatedConversation(int id, AnnotatedConversation annotatedConversation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != annotatedConversation.Id) { return(BadRequest()); } db.Entry(annotatedConversation).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AnnotatedConversationExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetAnnotatedConversation(int id) { AnnotatedConversation annotatedConversation = await db.AnnotatedConversations.FindAsync(id); if (annotatedConversation == null) { return(NotFound()); } return(Ok(annotatedConversation)); }
public async Task <IHttpActionResult> DeleteAnnotatedConversation(int id) { AnnotatedConversation annotatedConversation = await db.AnnotatedConversations.FindAsync(id); if (annotatedConversation == null) { return(NotFound()); } db.AnnotatedConversations.Remove(annotatedConversation); await db.SaveChangesAsync(); return(Ok(annotatedConversation)); }