public void DeletePost(PostThread post) { using (ForumDBContext dc = conn.GetContext()) { dc.PostThreads.DeleteObject(dc.PostThreads.Where (ac => ac.PostID.Equals(post.PostID)).FirstOrDefault()); dc.SaveChanges(); } }
public void DeleteComment(Comment comment) { using (ForumDBContext dc = conn.GetContext()) { dc.Comments.DeleteObject(dc.Comments.Where (ac => ac.CommentID.Equals(comment.CommentID)).FirstOrDefault()); dc.SaveChanges(); } }
public PostThread SavePost(PostThread post) { using (ForumDBContext dc = conn.GetContext()) { if (post.PostID > 0) { dc.PostThreads.Attach(new PostThread { PostID = post.PostID }); dc.PostThreads.ApplyCurrentValues(post); } else { dc.PostThreads.AddObject(post); } dc.SaveChanges(); } return(post); }
public Comment SaveComment(Comment comment) { using (ForumDBContext dc = conn.GetContext()) { if (comment.CommentID > 0) { dc.Comments.Attach(new Comment { CommentID = comment.CommentID }); dc.Comments.ApplyCurrentValues(comment); } else { dc.Comments.AddObject(comment); } dc.SaveChanges(); } return(comment); }