示例#1
0
        // Tests receiving threads of a given ID
        private static async Task TestThreads()
        {
            // Retrieves threads and displays result
            Console.Write("Enter the ID of the thread to view\n> ");
            int id = int.Parse(Console.ReadLine());

            Console.Clear();
            Result <ApiThread> response = await client.GetThreadAsync(id);

            // Outputs result
            if (response.Success)
            {
                DisplayItems.DisplayThread(response.Value);
            }
            else
            {
                DisplayItems.DisplayError(response);
            }
        }
示例#2
0
        // Tests creating a thread
        private static async Task TestCreateThread()
        {
            // Receives user input and creates thread
            Console.Write("Thread title: ");
            string title = Console.ReadLine();

            Console.Write("Thread contents: ");
            string             contents = Console.ReadLine();
            Result <ApiThread> result   = await client.CreateThreadAsync(title, contents);

            // Output result
            if (result.Success)
            {
                DisplayItems.DisplayThread(result.Value);
            }
            else
            {
                DisplayItems.DisplayError(result);
            }
        }
示例#3
0
        // Tests retrieving threads from the front page
        private static async Task TestFrontPage()
        {
            // Retrieves list of threads for the given page
            Console.Write("Select a page to view\n> ");
            int page = int.Parse(Console.ReadLine());

            Console.Clear();
            Result <List <ApiThread> > response = await client.GetFrontPageAsync(page);

            // Outputs result
            if (response.Success)
            {
                Console.WriteLine(separator);
                foreach (ApiThread thread in response.Value)
                {
                    DisplayItems.DisplayThread(thread);
                    Console.WriteLine(separator);
                }
            }
            else
            {
                DisplayItems.DisplayError(response);
            }
        }