Save() 공개 메소드

public Save ( Post entity ) : int
entity Post
리턴 int
        private int CreatePost(string title, string text, DateTime published)
        {
            IPostRepository repo = new PostRepository(new BlogContext());

            var post = new Post
                           {
                               Title = title,
                               Text = text,
                               PublishDate = published
                           };

            return repo.Save(post);
        }
예제 #2
0
        private int CreatePost(string title, string text, DateTime published, params Comment[] comments)
        {
            IPostRepository repo = new PostRepository(new BlogContext());

            var post = new Post
                           {
                               Title = title,
                               Text = text,
                               PublishDate = published
                           };

            post.Comments = new Collection<Comment>();

            foreach(var comment in comments)
            {
                post.Comments.Add(new Comment() { Text = comment.Text, Author = comment.Author});
            }

            return repo.Save(post);
        }