public Comic[] GetComics() { string result = this.getResultStringFromEndpoint("comics"); ComicDataWrapper comics = JsonConvert.DeserializeObject <ComicDataWrapper>(result); return(comics.Data.Results); }
public async Task <IActionResult> Hero(string searchString) { var _marvel = new MarvelApi.Marvel(); CharacterDataWrapper CharacterModel = await _marvel.GetCharacters(searchString); Character _character = CharacterModel.Data.Results.FirstOrDefault(); ComicDataWrapper comicModel = await _marvel.GetComicsForCharacter(_character.Id); List <Comic> _comics = comicModel.Data.Results; List <Comic> _ComicsWithImages = new List <Comic>(3); int count = 0; //some of the data is not in the api db. So skip the comics that do not have images and trim the description foreach (var comic in _comics) { int pathlength = 0; if (count == 3) { break; } //Truncate the description if it is too long if (!String.IsNullOrEmpty(comic.Description)) { if (comic.Description.Length > 360) { comic.Description = comic.Description.Substring(0, 360) + " ..."; } } pathlength = comic.Thumbnail.Path.Length; if (comic.Thumbnail.Path.Substring(pathlength - 19, 19) != "image_not_available") { _ComicsWithImages.Add(comic); count++; } } CharacterComicViewModel ccVM = new CharacterComicViewModel(); ccVM.Character = _character; ccVM.Comics = _ComicsWithImages; ccVM.AttributionText = CharacterModel.AttributionText; return(View(ccVM)); }
public async Task <IActionResult> ComicDetails(int?id, string title) { MarvelApi marvel = new MarvelApi(); ComicDataWrapper apiComic = new ComicDataWrapper(); if (id == null && title == null) { return(NotFound()); } if (id != null) { apiComic = await marvel.GetComicId(id); } if (title != null) { apiComic = await marvel.GetComicByTitle(title); } IEnumerable <Comic> comicList = apiComic.Data.Results; return(View(comicList)); }