public IActionResult Species(int Id) { try { IEnumerable <AnimalListingViewModel> animals = _animalService.GetBySpecies(Id) .Select(animal => new AnimalListingViewModel { Id = animal.Id, Name = animal.Name, Age = animal.Age, Gender = animal.Gender, Species = animal.Species, Breed = animal.Breed, Color = animal.Color, AnimalRestrictions = animal.AnimalRestrictions, Media = animal.Media }); var species = _speciesService.GetById(Id); var model = new AnimalSpeciesViewModel { Species = species, AnimalList = animals }; return(View(model)); } catch (Exception ex) { ErrorViewModel error = new ErrorViewModel(); error.Message = ex.Message; return(RedirectToAction("Error", "Home", error)); } }