예제 #1
0
 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());
 }
예제 #2
0
 public async Task <IReadOnlyCollection <DogDTO> > Get()
 {
     return(_mapper.mapper.Map <IReadOnlyCollection <DogDTO> >(await _repository.Get()));
 }
예제 #3
0
        public IEnumerable <DogViewModel> Get()
        {
            var dogs = _repository.Get();

            return(dogs.Select(dog => _mapper.Map <Dog, DogViewModel>(dog)));
        }
예제 #4
0
        public IEnumerable <ViewModels.Dog> Get()
        {
            var dogs = repository.Get();

            return(dogs.Select(dog => mapper.Map <DataAccess.Entity.Dog, ViewModels.Dog>(dog)));
        }
예제 #5
0
 // GET: api/Dog/5
 public Dog Get(int id)
 {
     return(dogRepository.Get(id));
 }