コード例 #1
0
        static async Task <List <Magazine> > GetMagazines(string token, string category)
        {
            //client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            HttpResponseMessage response = await client.GetAsync(apiBaseAddress + "api/magazines/" + token + "/" + category);

            if (response.IsSuccessStatusCode)
            {
                string    result    = response.Content.ReadAsStringAsync().Result;
                Magazines magazines = JsonConvert.DeserializeObject <Magazines>(result);
                return(magazines.Data);
            }
            return(null);
        }
コード例 #2
0
        static async Task <List <Magazine> > GetAllMagazines(string token, List <string> categories)
        {
            Magazines magazines = new Magazines();

            magazines.Data = new List <Magazine>();
            foreach (string category in categories)
            {
                List <Magazine> _magazines = await GetMagazines(token, category.ToString());

                magazines.Data.AddRange(_magazines);
            }

            return(magazines.Data);
        }