Esempio n. 1
0
        public async Task <ActionResult <PlayerToReturnDto> > GetPlayer(int id)
        {
            var spec   = new PlayersWithCountryAndGamesSpecification(id);
            var player = await _playersRepo.GetEntityWithSpec(spec);

            var playerToReturn = _mapper.Map <Player, PlayerToReturnDto>(player);

            return(Ok(playerToReturn));
            // return Ok(player);
        }
Esempio n. 2
0
        public async Task <ActionResult <Pagination <PlayerToReturnDto> > > GetPlayers([FromQuery] PlayerSpecParams playerParams)
        {
            var spec       = new PlayersWithCountryAndGamesSpecification(playerParams);
            var countSpec  = new PlayerWithFiltersForCountSpecificication(playerParams);
            var totalItems = await _playersRepo.CountAsync(countSpec);

            var players = await _playersRepo.ListAsync(spec);

            var playersToReturn = _mapper.Map <IReadOnlyList <Player>, IReadOnlyList <PlayerToReturnDto> >(players);
            var Paginations     = new Pagination <PlayerToReturnDto>(playerParams.PageIndex, playerParams.PageSize, totalItems, playersToReturn);

            return(Ok(Paginations));
        }