public async Task <IQueryable <PlayerDTO> > GetPlayers() { IEnumerable <Player> players = await _repository.Players().GetAllAsync(); IEnumerable <PlayerDTO> playerDTOs = _factory.GetDTOCollection(players); IQueryable <PlayerDTO> oDataPlayerDTOs = playerDTOs.AsQueryable <PlayerDTO>(); return(oDataPlayerDTOs); }
public async Task <IQueryable <PlayerDTO> > GetTeamPlayers([FromUri] int id) { Team team; //try to get requested team try { team = await _repository.Teams().FindSingleAsync(t => t.Id == id); } catch (InvalidOperationException) { throw; } //if doesn't exist send not found response if (team == null) { throw new ObjectNotFoundException("Could not find team Id=" + team.Id + "."); } IEnumerable <PlayerDTO> playerDTOs = _playerFactory.GetDTOCollection(team.Players); IQueryable <PlayerDTO> oDataPlayerDTOs = playerDTOs.AsQueryable(); return(oDataPlayerDTOs); }