Exemplo n.º 1
0
        public static Comment AddComment(Comment comment)
        {
            PostCommentContext context = new PostCommentContext();

            context.Comments.Add(comment);
            context.SaveChanges();
            return(comment);
        }
Exemplo n.º 2
0
        public static Post AddPost(Post post)
        {
            PostCommentContext context = new PostCommentContext();

            context.Posts.Add(post);
            context.SaveChanges();
            return(post);
        }
Exemplo n.º 3
0
        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();
        }