Ejemplo n.º 1
0
        public string ObterDadosContagem()
        {
            var resultado = _client.GetFromJsonAsync <ResultadoContador>(
                _configuration.GetSection("UrlAPIContagem").Value).Result;
            string jsonResultado = JsonSerializer.Serialize(resultado);

            _logger.LogInformation(
                $"Resultado: {jsonResultado}");

            LogFileHelper.WriteMessage(jsonResultado);

            return($"Valor atual do contador: {resultado.ValorAtual}");
        }
        public void EnviarRequisicao()
        {
            var response = _client.GetAsync(
                _configuration.GetSection("UrlAPIContagem").Value).Result;

            string resultado =
                response.Content.ReadAsStringAsync().Result;

            if (response.IsSuccessStatusCode)
            {
                _logger.LogInformation("Resultado normal: " + resultado);
            }
            else
            {
                _logger.LogError("Erro: " + resultado);
            }
            LogFileHelper.WriteMessage(resultado);

            response.EnsureSuccessStatusCode();
        }