Skip to content

Commit

Permalink
fix: 123402 AB#123402 Merge pull request #14807 from prefeiturasp/fix…
Browse files Browse the repository at this point in the history
…/123402

Bug: 123402
  • Loading branch information
robsonamcom authored Aug 30, 2024
2 parents f3184eb + 1410c4b commit 6988c44
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,20 +23,23 @@ public ObterMatriculasAlunoPorCodigoEAnoQueryHandler(IHttpClientFactory httpClie

public async Task<IEnumerable<AlunoPorTurmaResposta>> Handle(ObterMatriculasAlunoPorCodigoEAnoQuery request, CancellationToken cancellationToken)
{
var alunos = Enumerable.Empty<AlunoPorTurmaResposta>();

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<List<AlunoPorTurmaResposta>>(json);
return JsonConvert.DeserializeObject<List<AlunoPorTurmaResposta>>(json);

} else if (resposta.StatusCode == HttpStatusCode.NotFound || resposta.StatusCode == HttpStatusCode.NoContent)
{
return Enumerable.Empty<AlunoPorTurmaResposta>();
}

return alunos;
throw new Exception(json);
}
}
}

0 comments on commit 6988c44

Please sign in to comment.