예제 #1
0
        public async Task <IActionResult> GetMatchDayPlayers(
            [FromRoute] string id,
            [FromQuery] string orderBy = "Date",
            [FromQuery] bool desc      = false,
            [FromQuery] int pageSize   = 10,
            [FromQuery] int page       = 0)
        {
            var tenantId = this.GetTenantId();
            var players  = await _matchDayService.GetMatchDayPlayers(id, tenantId);

            var response = HandicapResponse <PlayerResponse, Player> .Create(players, null, page, pageSize, _mapper);

            return(Ok(response));
        }
예제 #2
0
        public async Task <IActionResult> GetOpenMatchDays(
            [FromQuery] string orderBy = "Date",
            [FromQuery] bool desc      = false,
            [FromQuery] int pageSize   = 10,
            [FromQuery] int page       = 0
            )
        {
            var tenantId      = this.GetTenantId();
            var matchDayQuery = await _matchDayService.Find(m => m.TenantId == tenantId && !m.IsFinished);

            matchDayQuery = desc ?
                            matchDayQuery.OrderByDescending(orderBy)
                : matchDayQuery.OrderBy(orderBy);

            var response = HandicapResponse <MatchDayResponse, MatchDay> .Create(matchDayQuery, null, page, pageSize, _mapper);

            return(Ok(response));
        }
예제 #3
0
        public async Task <IActionResult> GetAvailablePlayers(
            [FromRoute] string id,
            [FromQuery] string orderBy = "FirstName",
            [FromQuery] bool desc      = false,
            [FromQuery] int pageSize   = 10,
            [FromQuery] int page       = 0)
        {
            var tenantId             = this.GetTenantId();
            var availablePlayerQuery = (await _matchDayService.GetAvailablePlayers(id, tenantId));

            availablePlayerQuery = desc ?
                                   availablePlayerQuery.OrderByDescending(orderBy)
                : availablePlayerQuery.OrderBy(orderBy);

            var response = HandicapResponse <PlayerResponse, Player> .Create(availablePlayerQuery, null, page, pageSize, _mapper);

            return(Ok(response));
        }
예제 #4
0
        public async Task <IActionResult> GetMatchDayGames(
            [FromRoute] string id,
            [FromQuery] string orderBy = "Date",
            [FromQuery] bool desc      = false,
            [FromQuery] int pageSize   = 10,
            [FromQuery] int page       = 0)
        {
            var tenantId = this.GetTenantId();
            var games    = await _matchDayService.GetMatchDayGames(id, tenantId);

            games = desc ?
                    games.OrderByDescending(orderBy)
                : games.OrderBy(orderBy);

            var response = HandicapResponse <GameResponse, Game> .Create(games, null, page, pageSize, _mapper);

            return(Ok(response));
        }
예제 #5
0
        public async Task <IActionResult> Get(
            [FromQuery] string orderBy = "LastName",
            [FromQuery] bool desc      = false,
            [FromQuery] int pageSize   = 10,
            [FromQuery] int page       = 0
            )
        {
            var tenantId = this.GetTenantId();

            var query = await _playerService.Find(p => p.TenantId == tenantId);

            //var responseQuery = query.ProjectTo<PlayerResponse>(_mapper.ConfigurationProvider);
            query = desc ?
                    query.OrderByDescending(orderBy)
                : query.OrderBy(orderBy);

            var response = HandicapResponse <PlayerResponse, Player> .Create(query, null, page, pageSize, _mapper);

            return(Ok(response));
        }
예제 #6
0
        public async Task <IActionResult> Get(
            [FromQuery] string orderBy = "Date",
            [FromQuery] bool desc      = false,
            [FromQuery] int pageSize   = 10,
            [FromQuery] int page       = 0)
        {
            var tenantId = this.GetTenantId();

            var query = await _gameService.Find(g => g.TenantId == tenantId,
                                                nameof(Game.PlayerOne),
                                                nameof(Game.PlayerTwo));

            query = desc ?
                    query.OrderByDescending(orderBy)
                : query.OrderBy(orderBy);

            //var responseQuery = query.ProjectTo<GameResponse>(_mapper.ConfigurationProvider);

            var response = HandicapResponse <GameResponse, Game> .Create(query, null, page, pageSize, _mapper);

            return(Ok(response));
        }
예제 #7
0
        public async Task <IActionResult> GetGamesFromPlayer(
            [FromRoute] string id,
            [FromQuery] string orderBy = "Date",
            [FromQuery] bool desc      = false,
            [FromQuery] int pageSize   = 10,
            [FromQuery] int page       = 0)
        {
            var tenantId = this.GetTenantId();

            var games = await _gameService.Find(g => g.TenantId == tenantId,
                                                nameof(Game.PlayerOne),
                                                nameof(Game.PlayerTwo));

            games = games.Where(g => g.PlayerOne.Id == id || g.PlayerTwo.Id == id);
            games = desc ?
                    games.OrderByDescending(orderBy)
                : games.OrderBy(orderBy);

            var response = HandicapResponse <GameResponse, Game> .Create(games, null, page, pageSize, _mapper);

            return(Ok(response));
        }