public ActionResult <ApiDog> Get(int id) { if (dogRepository.Get(id) is Dog dog) { // convenience of ActionResult<T> return type (implemented via custom implicit cast)... // can return an IActionResult, or, a T (wrapped in OkResult) return(new ApiDog { Id = dog.Id, Name = dog.Name }); } return(NotFound()); }
public async Task <IReadOnlyCollection <DogDTO> > Get() { return(_mapper.mapper.Map <IReadOnlyCollection <DogDTO> >(await _repository.Get())); }
public IEnumerable <DogViewModel> Get() { var dogs = _repository.Get(); return(dogs.Select(dog => _mapper.Map <Dog, DogViewModel>(dog))); }
public IEnumerable <ViewModels.Dog> Get() { var dogs = repository.Get(); return(dogs.Select(dog => mapper.Map <DataAccess.Entity.Dog, ViewModels.Dog>(dog))); }
// GET: api/Dog/5 public Dog Get(int id) { return(dogRepository.Get(id)); }