Exemplo n.º 1
0
        public List <SaveCategoryResource> ProcessCategoryData(RawCategoriesList rawCategoriesList)
        {
            List <SaveCategoryResource> categories = new List <SaveCategoryResource>();

            foreach (RawCategoryModel rawCat in rawCategoriesList.Drinks)
            {
                categories.Add(new SaveCategoryResource()
                {
                    Name = rawCat.StrCategory
                });
            }
            return(categories);
        }
Exemplo n.º 2
0
        public async Task <RawCategoriesList> LoadCategories()
        {
            string url = "https://www.thecocktaildb.com/api/json/v1/1/list.php?c=list";

            using (HttpResponseMessage response = await ApiHelper.HttpClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    RawCategoriesList RawCategories = await response.Content.ReadAsAsync <RawCategoriesList>();

                    return(RawCategories);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }