public static Comment AddComment(Comment comment) { PostCommentContext context = new PostCommentContext(); context.Comments.Add(comment); context.SaveChanges(); return(comment); }
public static Post AddPost(Post post) { PostCommentContext context = new PostCommentContext(); context.Posts.Add(post); context.SaveChanges(); return(post); }
public static void DeletePost(Guid id) { PostCommentContext context = new PostCommentContext(); Post post = GetPostById(id); if (post == null) { throw new NotFoundException(); } context.Posts.Remove(post); context.SaveChanges(); }