Exemple #1
0
        public async Task <ActionResult <PaginatedCollection <RankingEntryLight> > > GetRankingAsync(
            [FromRoute] Game game,
            [FromRoute] DateTime?date,
            [FromQuery] int page,
            [FromQuery] int count,
            [FromQuery] bool full,
            [FromQuery] long?simulatedPlayerId)
        {
            var request = new RankingRequest
            {
                Game        = game,
                FullDetails = full
            };

            var now = ServiceProviderAccessor.ClockProvider.Now;

            if (simulatedPlayerId.HasValue && date.HasValue)
            {
                request.PlayerVsLegacy = (simulatedPlayerId.Value, date.Value);
                request.RankingDate    = now;
            }
            else
            {
                request.RankingDate = date ?? now;
            }

            var rankingEntries = await _statisticsProvider
                                 .GetRankingEntriesAsync(request)
                                 .ConfigureAwait(false);

            return(Ok(PaginatedCollection <RankingEntryLight> .CreateInstance(rankingEntries, page, count)));
        }