public async Task <IHttpActionResult> PostCommentComment(CommentComment commentComment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CommentComments.Add(commentComment); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (CommentCommentExists(commentComment.id)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = commentComment.id }, commentComment)); }
public async Task <IHttpActionResult> PutCommentComment(Guid id, CommentComment commentComment) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != commentComment.id) { return(BadRequest()); } db.Entry(commentComment).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentCommentExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetCommentComment(Guid id) { CommentComment commentComment = await db.CommentComments.FindAsync(id); if (commentComment == null) { return(NotFound()); } return(Ok(commentComment)); }
public async Task <IHttpActionResult> DeleteCommentComment(Guid id) { CommentComment commentComment = await db.CommentComments.FindAsync(id); if (commentComment == null) { return(NotFound()); } db.CommentComments.Remove(commentComment); await db.SaveChangesAsync(); return(Ok(commentComment)); }