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)); }
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)); }
public JsonResult Comic(int id, ComicApi.Direction dir = ComicApi.Direction.Next) { return(Json(ComicApi.GetByNumber(id, dir), JsonRequestBehavior.AllowGet)); }
public JsonResult Today() { return(Json(ComicApi.GetTodayComic(), JsonRequestBehavior.AllowGet)); }