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); }
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); }