Exemplo n.º 1
0
        // GET: Animals/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var animal = await _animalRepository.GetAnimalWithUserAsync(id.Value);

            if (animal == null)
            {
                return(NotFound());
            }

            var user = await _userHelper.GetUserByEmailAsync(this.User.Identity.Name);

            if (this.User.IsInRole("Client") && animal.User != user)
            {
                return(NotFound());
            }

            var appointments = _appointmentRepository.GetAnimalAppointments(animal.Id);

            var model = _converterHelper.ToAnimalDetailsViewModel(animal, appointments);

            return(View(model));
        }