public async Task <IActionResult> Index(AnimalType?animalType, Gender?gender, DeepBoolean?canBeWithKids) { AnimalIndexModel model = new AnimalIndexModel(); string baseUrl = "https://localhost:44353/api/animals?"; if (animalType != null) { baseUrl += "animalType=" + animalType.ToString() + "&"; model.animalType = animalType.ToString(); } if (gender != null) { baseUrl += "gender=" + gender.ToString() + "&"; model.gender = gender.ToString(); } if (canBeWithKids != null) { baseUrl += "canBeWithKids=" + canBeWithKids.ToString(); model.canBeWithKids = canBeWithKids.ToString(); } var response = await baseUrl.GetStringAsync(); model.animalList = JsonConvert.DeserializeObject <List <Animal> >(response); model.animalTypes = new SelectList(Enum.GetValues(typeof(AnimalType)).Cast <AnimalType>().ToList(), animalType.ToString()); model.genders = new SelectList(Enum.GetValues(typeof(Gender)).Cast <Gender>().ToList(), gender.ToString()); model.canBeWithKidsList = new SelectList(Enum.GetValues(typeof(DeepBoolean)).Cast <DeepBoolean>().ToList(), canBeWithKids.ToString()); return(View(model)); }
// GET: Animales public async Task <IActionResult> Index() { var data = await _context.Animales.Include(x => x.Especie).Select(x => x).ToListAsync(); var model = new AnimalIndexModel { Data = Map <List <AnimalIndexDataModel> >(data) }; return(View(model)); }