Пример #1
0
        // Tests getting comments by ID
        private static async Task TestGetComment()
        {
            // Receives user input and retrieves comment
            Console.Write("Enter the id of the comment to retrieve\n> ");
            int id = int.Parse(Console.ReadLine());
            Result <ApiComment> result = await client.GetCommentAsync(id);

            // Outputs result
            if (result.Success)
            {
                DisplayItems.DisplayComment(result.Value);
            }
            else
            {
                DisplayItems.DisplayError(result);
            }
        }
Пример #2
0
        // Tests posting a comment
        private static async Task TestPostComment()
        {
            // Receives user input and posts comment
            Console.Write("Enter the ID of the post to comment on\n> ");
            int id = int.Parse(Console.ReadLine());

            Console.Write("Enter the contents of the comment to post\n> ");
            string content             = Console.ReadLine();
            Result <ApiComment> result = await client.PostCommentAsync(id, content);

            // Outputs result
            if (result.Success)
            {
                DisplayItems.DisplayComment(result.Value);
            }
            else
            {
                DisplayItems.DisplayError(result);
            }
        }
Пример #3
0
        // Tests retrieving comments of a thread
        private static async Task TestThreadComments()
        {
            // Receives user input and retrieves comment
            Console.Write("Enter the ID of the thread to retrieve\n> ");
            int id = int.Parse(Console.ReadLine());

            Console.Write("Enter the page of the comments to view\n> ");
            int page = int.Parse(Console.ReadLine());
            Result <List <ApiComment> > result = await client.GetThreadCommentsAsync(id, page);

            // Outputs result
            if (result.Success)
            {
                foreach (ApiComment comment in result.Value)
                {
                    DisplayItems.DisplayComment(comment);
                }
                Console.WriteLine(separator);
            }
            else
            {
                DisplayItems.DisplayError(result);
            }
        }