public async Task <IEnumerable <AnimalResponse> > GetAllAsync() { var response = await _service.GetAllAsync(); var ordered = response.OrderBy(animal => animal.Added); // animal as AnimalResponse var cast = ordered.Select(animal => { var castAnimal = (AnimalResponse)animal; return(castAnimal); }); return(cast); }
public async Task <IActionResult> GetAsync( [FromQuery] AnimalsFiltrationQuery query, [FromQuery] PaginationQuery paginationQuery) { var pagination = _mapper.Map <PaginationFilter>(paginationQuery); var filter = _mapper.Map <AnimalsFilter>(query); var animals = await _animalService.GetAllAsync(filter, pagination); var result = animals.Select(x => _mapper.Map <ReadAnimalDto>(x)); var pagedResponse = new PagedResponse <ReadAnimalDto>(result, paginationQuery); return(Ok(pagedResponse)); }
public async Task <IEnumerable <AnimalDto> > Get(string email) { return(await _animalService.GetAllAsync(email)); }
public async Task <IActionResult> GetAll() { return(Ok(await _animalService.GetAllAsync())); }