Beispiel #1
0
        public async Task <IEnumerable <Game> > GetGames(
            ScheduleQueryParameter queryParameter,
            CancellationToken cancellationToken)
        {
            using var scope = _tracer.InitializeTrace(nameof(GetGames));

            scope.LogStart(nameof(GetGames));

            var currentSeason = StringParser.GetCurrentSeason();
            var season        = queryParameter.Season ?? currentSeason;

            var games = await _gameRepository.GetGamesForSeason(season, cancellationToken);

            if (!string.IsNullOrWhiteSpace(queryParameter.Team))
            {
                games = games.Where(x =>
                                    string.Equals(x.HomeTeam, queryParameter.Team, StringComparison.OrdinalIgnoreCase) ||
                                    string.Equals(x.AwayTeam, queryParameter.Team, StringComparison.OrdinalIgnoreCase));
            }

            if (queryParameter.Week != null)
            {
                games = games.Where(x => x.Week == queryParameter.Week);
            }

            scope.LogEnd(nameof(GetGames));

            return(games);
        }
        public void ScheduleQueryParameter_InvalidSeason()
        {
            var parameters = new ScheduleQueryParameter()
            {
                Season = 2099
            };

            var errors = parameters.Validate();

            Assert.AreEqual(1, errors.Count);
        }
        public void ScheduleQueryParameter_InvalidWeekNumber()
        {
            var parameters = new ScheduleQueryParameter()
            {
                Week = 99
            };

            var errors = parameters.Validate();

            Assert.AreEqual(1, errors.Count);
        }
        public async Task <ActionResult <IEnumerable <Game> > > GetSchedule(
            [FromQuery] ScheduleQueryParameter queryParameter,
            CancellationToken cancellationToken)
        {
            var errors = queryParameter.Validate();

            if (errors.Count > 0)
            {
                return(BadRequestError(errors));
            }

            var games = await _scheduleService.GetGames(queryParameter, cancellationToken);

            _logger.LogInformation("Successful Games request");
            _tracer.ActiveSpan.SetTags(
                HttpContext.Request.GetDisplayUrl(),
                HttpContext.Connection.RemoteIpAddress.MapToIPv6().ToString());

            return(Ok(games));
        }
Beispiel #5
0
 public Task <IPaged <ScreeningRoom> > PagedAsync(ScheduleQueryParameter param, int pageIndex, int pageSize)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public Task <List <ScreeningRoom> > SelectAsync(ScheduleQueryParameter param)
 {
     throw new NotImplementedException();
 }