public async Task <ActionResult <VideoGameToReturnDto> > GetVideoGames(int id) { var spec = new VideoGamesWithDevelopersAndPublishersSpecifications(id); var videoGame = await _videoGameRepo.GetEntityWithSpec(spec); if (videoGame == null) { return(NotFound(new ApiResponse(400))); } return(Ok(mapper.Map <VideoGame, VideoGameToReturnDto>(videoGame))); }
public async Task <ActionResult <Pagination <VideoGameToReturnDto> > > GetVideoGames([FromQuery] VideoGameSpecParams videoGameParams) { var spec = new VideoGamesWithDevelopersAndPublishersSpecifications(videoGameParams); var countSpec = new VideoGameWithFiltersForCountSpecification(videoGameParams); var totalItems = await _videoGameRepo.CountAsync(countSpec); var videoGames = await _videoGameRepo.ListAsync(spec); var data = mapper.Map <IReadOnlyList <VideoGame>, IReadOnlyList <VideoGameToReturnDto> >(videoGames); return(Ok(new Pagination <VideoGameToReturnDto>(videoGameParams.PageIndex, videoGameParams.PageSize, totalItems, data))); }