public async Task <ActionResult <PetDetails> > FindPet(int petId, CancellationToken cancellationToken) { var pet = await _petsRepo.FindById(petId, cancellationToken); if (pet == null) { throw new ResourceNotFoundException("Pet " + petId + " not found"); } return(Ok(new PetDetails(pet.Id, pet.Name, pet.Owner.FirstName + " " + pet.Owner.LastName, pet.BirthDate, DTOs.PetType.ToDTO(pet.PetType)))); }
public async Task <ActionResult <PetDetails> > FindPet(int petId, CancellationToken cancellationToken) { var pet = await _petsRepo.FindById(petId, cancellationToken); if (pet == null) { throw new ResourceNotFoundException("Pet " + petId + " not found"); } var ret = new PetDetails(pet); return(Ok(ret)); }