public IActionResult Index() { try { IEnumerable <AnimalListingViewModel> animals = _animalService.GetAll() .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 model = new AnimalIndexViewModel { AnimalList = animals }; return(View(model)); } catch (Exception ex) { ErrorViewModel error = new ErrorViewModel(); error.Message = ex.Message; return(RedirectToAction("Error", "Home", error)); } }