Example #1
0
        private async Task <string> GetResultByIntervalAsync(TimeInterval timeInterval)
        {
            _logger.LogInformation("class IntervalResultsMenu. GetResultByIntervalAsync()");

            var options = new string[] { "Set the amount of last days/hours/minutes for statistics", "Show all days/hours/minutes for statistics" };
            var command = MenuLibrary.InputMenuItemNumber("Please, choose", options);

            var amount = command == 1
                ? MenuLibrary.InputIntegerValue("amount", 1, int.MaxValue)
                : int.MaxValue;

            var response = await _statisticClient.GetUserResultByIntervalAsync(amount, timeInterval);

            _logger.LogInformation("REQUEST: Sent the response to get the statistics");

            if (response.StatusCode == HttpStatusCode.OK)
            {
                _logger.LogInformation("RESPONSE: Get the statistics (200)");

                var content = await response.Content.ReadAsStringAsync();

                return(content);
            }
            else
            {
                _logger.LogInformation("RESPONSE: Unknown response");
                throw new HttpListenerException();
            }
        }
        private async Task <string> GetStatistcsAsync(StatisticsType type)
        {
            _logger.LogInformation("class LeaderboardMenu. GetStatistcsAsync()");

            var options = new string[] { "Set the amount of best players in the rate", "Show all players in the rate" };
            var command = MenuLibrary.InputMenuItemNumber("Please, choose", options);

            var amount = command == 1
                ? MenuLibrary.InputIntegerValue("amount", 1, int.MaxValue)
                : int.MaxValue;

            var response = await _statisticClient.GetLeaderboardAsync(amount, type);

            _logger.LogInformation("REQUEST: Sent the request for statistics");

            if (response.StatusCode == HttpStatusCode.OK)
            {
                _logger.LogInformation("RESPONSE: Got the statistics (200)");

                var content = await response.Content.ReadAsStringAsync();

                return(content);
            }
            else
            {
                _logger.LogInformation("RESPONSE: Unknown response");
                throw new HttpListenerException();
            }
        }