From 1410c4b59b291794f73b89121780a8bd9a8e4ee9 Mon Sep 17 00:00:00 2001 From: "Rayane M. Santos" Date: Thu, 29 Aug 2024 18:10:51 -0300 Subject: [PATCH] fix(123402): Corrige retorno querie ObterMatriculasAlunoPorCodigoEAnoQuery --- ...terMatriculasAlunoPorCodigoEAnoQueryHandler.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/SME.SGP.Aplicacao/Queries/Aluno/ObterMatriculasAlunoPorCodigoEAno/ObterMatriculasAlunoPorCodigoEAnoQueryHandler.cs b/src/SME.SGP.Aplicacao/Queries/Aluno/ObterMatriculasAlunoPorCodigoEAno/ObterMatriculasAlunoPorCodigoEAnoQueryHandler.cs index ccc9918095..4b451d39a8 100644 --- a/src/SME.SGP.Aplicacao/Queries/Aluno/ObterMatriculasAlunoPorCodigoEAno/ObterMatriculasAlunoPorCodigoEAnoQueryHandler.cs +++ b/src/SME.SGP.Aplicacao/Queries/Aluno/ObterMatriculasAlunoPorCodigoEAno/ObterMatriculasAlunoPorCodigoEAnoQueryHandler.cs @@ -1,9 +1,11 @@ using MediatR; using Newtonsoft.Json; +using SME.SGP.Dominio; using SME.SGP.Infra; using System; using System.Collections.Generic; using System.Linq; +using System.Net; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -21,20 +23,23 @@ public ObterMatriculasAlunoPorCodigoEAnoQueryHandler(IHttpClientFactory httpClie public async Task> Handle(ObterMatriculasAlunoPorCodigoEAnoQuery request, CancellationToken cancellationToken) { - var alunos = Enumerable.Empty(); - var httpClient = httpClientFactory.CreateClient(ServicosEolConstants.SERVICO); var resposta = await httpClient.GetAsync( string.Format(ServicosEolConstants.URL_ALUNOS_TURMAS_ANOS_LETIVOS_HISTORICO_FILTRAR_SITUACAO, request.CodigoAluno, request.AnoLetivo, request.Historico, request.FiltrarSituacao, request.TipoTurma), cancellationToken); + + var json = await resposta.Content.ReadAsStringAsync(cancellationToken); if (resposta.IsSuccessStatusCode) { - var json = await resposta.Content.ReadAsStringAsync(cancellationToken); - alunos = JsonConvert.DeserializeObject>(json); + return JsonConvert.DeserializeObject>(json); + + } else if (resposta.StatusCode == HttpStatusCode.NotFound || resposta.StatusCode == HttpStatusCode.NoContent) + { + return Enumerable.Empty(); } - return alunos; + throw new Exception(json); } } }