Пример #1
0
        private async Task GetComics(Character superHero)
        {
            if (superHero.ComicsAvailable != 0 && ListComic.Count == 0)
            {
                try
                {
                    HttpClient http     = new HttpClient();
                    var        peticion = await http.GetAsync("https://gateway.marvel.com/v1/public/comics?apikey=2c8c7e04677efe9a1a8625342ae2bac8&ts=10&hash=f8a89c483b2f946c754fc7262c34db1a" + "&limit=20" + "&characters=" + superHero.Id.ToString());

                    var respuesta = await peticion.Content.ReadAsStringAsync();

                    var objetoComic = ComicProxy.FromJson(respuesta);

                    ListComic.Clear();

                    foreach (var item in objetoComic.Data.Results)
                    {
                        Comic comic = new Comic();
                        comic.Title = item.Title;
                        if (item.Description == null)
                        {
                            item.Description = "";
                        }
                        comic.Description = item.Description;
                        comic.Thumbnail   = item.Thumbnail.Path + ".jpg";

                        ListComic.Add(comic);
                    }
                }
                catch (Exception ex)
                {
                    ItsBusy          = false;
                    LabelTextResults = "Error en la conexión.";
                }
            }
        }