//add comment public void POST(forum_comment foracomment) { using (ThyroidDataEntities entities = new ThyroidDataEntities()) { entities.forum_comment.Add(foracomment); entities.SaveChanges(); } }
//delete comment by comment id public string Delete(int id) { using (ThyroidDataEntities entities = new ThyroidDataEntities()) { forum_comment commentid = entities.forum_comment.Find(id); entities.forum_comment.Remove(commentid); entities.SaveChanges(); return("Comment Deleted Successfully"); } }
//update comment via comment id public void PUT(int id, forum_comment forumcomment) { using (ThyroidDataEntities entities = new ThyroidDataEntities()) { var fcomment = entities.forum_comment.Find(id); fcomment.comment = forumcomment.comment; fcomment.timestamp = forumcomment.timestamp; fcomment.username = forumcomment.username; entities.Entry(fcomment).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); } }