Example #1
0
        public ActionResult SearchComics([FromQuery] string name, int?pagina)
        {
            int takePagina = pagina ?? 1;


            dynamic resultados = _serviceApi.searchByName(name, takePagina);

            List <ComicApi> comicList = new List <ComicApi>();
            ComicApi        comic;
            CreatorSearch   creators;
            Character       characters;
            int             total = resultados.data.total;

            foreach (var result in resultados.data.results)
            {
                comic             = new ComicApi();
                comic.IdComicAPI  = result.id;
                comic.Title       = result.title;
                comic.PageCount   = result.pageCount;
                comic.Description = result.description;
                comic.ImageCover  = $"{result.thumbnail.path}.{result.thumbnail.extension}";

                foreach (var creatorResult in result.creators.items)
                {
                    if (creatorResult != null)
                    {
                        creators      = new CreatorSearch();
                        creators.Name = creatorResult.name;
                        creators.Role = creatorResult.role;
                        comic.Creators.Add(creators);
                    }
                }

                foreach (var characterResult in result.characters.items)
                {
                    if (characterResult != null)
                    {
                        characters      = new Character();
                        characters.Name = characterResult.name;
                        comic.Characters.Add(characters);
                    }
                }

                comicList.Add(comic);
            }

            return(Ok(comicList));
        }
Example #2
0
        public ActionResult SearchComics([FromQuery] int id)
        {
            dynamic resultados = _serviceApi.searchById(id);

            ComicApi      comic = new ComicApi();
            CreatorSearch creators;
            Character     characters;

            var result = resultados.data.results[0];

            comic.Title       = result.title;
            comic.PageCount   = result.pageCount;
            comic.Description = result.description;
            comic.ImageCover  = $"{result.thumbnail.path}.{result.thumbnail.extension}";

            foreach (var creatorResult in result.creators.items)
            {
                if (creatorResult != null)
                {
                    creators      = new CreatorSearch();
                    creators.Name = creatorResult.name;
                    creators.Role = creatorResult.role;
                    comic.Creators.Add(creators);
                }
            }

            foreach (var characterResult in result.characters.items)
            {
                if (characterResult != null)
                {
                    characters      = new Character();
                    characters.Name = characterResult.name;
                    comic.Characters.Add(characters);
                }
            }
            return(Ok(comic));
        }
Example #3
0
 public JsonResult Comic(int id, ComicApi.Direction dir = ComicApi.Direction.Next)
 {
     return(Json(ComicApi.GetByNumber(id, dir), JsonRequestBehavior.AllowGet));
 }
Example #4
0
 public JsonResult Today()
 {
     return(Json(ComicApi.GetTodayComic(), JsonRequestBehavior.AllowGet));
 }