Ejemplo n.º 1
0
 private static List <TriviaCategory> GetEntertainmentCategories(CategoryResponse catResponse)
 {
     //LINQ to Object
     //all entertainment categories sorted alphabetically
     return(catResponse.trivia_categories
            .Where(c => c.name.StartsWith("Entertainment"))
            .OrderBy(c => c.name)
            .ToList());
 }
Ejemplo n.º 2
0
        private async void Form1_Load(object sender, EventArgs e)
        {
            //Access the list of categoies from the Web API
            HttpResponseMessage response = await client.GetAsync("api_category.php");

            if (response.IsSuccessStatusCode)
            {
                string cats = await response.Content.ReadAsStringAsync();

                CategoryResponse catResponse = JsonConvert.DeserializeObject <CategoryResponse>(cats);

                List <TriviaCategory> entertainment = GetEntertainmentCategories(catResponse);
                PopulateCategoryComboBox(entertainment);
            }
        }