private static void GetPost(string title) { var postRepository = new PostRepository(); var post = postRepository.GetPostByTitle(title); if (post != null) { Console.WriteLine("Found post '{0}'", post.Title); if (post.Categories.Count > 0) { Console.WriteLine("Categories"); Console.WriteLine("-----------"); foreach (var category in post.Categories) { Console.WriteLine("- {0}", category.Name); } } if (post.Comments.Count > 0) { Console.WriteLine("Comments"); Console.WriteLine("-----------"); foreach (var comment in post.Comments) { Console.WriteLine("{0} said: {1}", comment.Author, comment.Text); } } } }
private static void DeletePost(string title) { var postRepository = new PostRepository(); var post = postRepository.GetPostByTitle(title); if (post != null) { postRepository.Delete(post); } }