Beispiel #1
0
            public async Task RunAsync()
            {
                var postId = await _blogPostService.CreateBlogPostAsync("My blog post!", "Awesome");

                var rng      = new Random();
                var comments = rng.Next(1, 3);
                var likes    = rng.Next(10, 30);

                for (var i = 0; i < comments; i++)
                {
                    await _blogPostService.CommentBlogPostAsync(postId, Guid.NewGuid().ToString());
                }

                for (var i = 0; i < likes; i++)
                {
                    await _blogPostService.LikeBlogPostAsync(postId);
                }

                var posts = await _blogPostService.GetTrendingBlogPostsAsync();

                foreach (var post in posts)
                {
                    Console.WriteLine($"{post.Title} - Comments: {string.Join(',', post.Comments.Select(x => x.Content))}, Likes: {post.Likes}.");
                }
            }