Esempio n. 1
0
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(this.NotFound());
            }
            var animal = await _animalRepository.GetByIdAsync(id.Value);

            if (animal == null)
            {
                return(this.NotFound());
            }
            animal.Breed = await _specieRepository.GetBreedByIdAsync(animal.BreedId);

            if (animal.Breed == null)
            {
                return(this.NotFound());
            }
            animal.Breed.Specie = await _specieRepository.GetSpecieAsync(animal.Breed);

            if (animal.Breed.Specie == null)
            {
                return(this.NotFound());
            }

            var model = _converterHelper.ToDetailsViewModel(animal);


            return(View(model));
        }