Skip to content

Commit

Permalink
refactor: use enumerable.Any() instead of Count() > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
guesant committed Apr 1, 2024
1 parent cf66c05 commit ef77f78
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions projeto-gerar-horario/GerarHorario/Gerador/Restricoes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ GerarHorarioContext contexto
propostaAula.DiarioId == diario.Id
select propostaAula.ModelBoolVar;

if (propostasDoDiario.Count() > 0)
if (propostasDoDiario.Any())
{
contexto.Model.Add(LinearExpr.Sum(propostasDoDiario) <= diario.QuantidadeMaximaSemana);
}
Expand All @@ -134,7 +134,7 @@ public static void AplicarLimiteDeNoMaximoUmDiarioAtivoPorTurmaEmUmHorario(Gerar
&& propostaAula.TurmaId == turma.Id // mesma turma
select propostaAula.ModelBoolVar).ToList();

if (propostas.Count > 0)
if (propostas.Any())
{
Console.WriteLine($"Dia: {diaSemanaIso} | Intervalo: {contexto.Options.HorariosDeAula[intervaloIndex]} | {turma.Id} | Quantidade de Propostas: {propostas.Count}");

Expand Down Expand Up @@ -169,7 +169,7 @@ public static void AplicarLimiteDeNoMaximoUmDiarioAtivoPorProfessorEmUmHorario(G
contexto.Options.ProfessorEstaVinculadoAoDiario(diarioId: propostaDeAula.DiarioId, professorId: professor.Id)
select propostaDeAula.ModelBoolVar;

if (propostas.Count() > 0)
if (propostas.Any())
{
contexto.Model.AddAtMostOne(propostas);
}
Expand Down

0 comments on commit ef77f78

Please sign in to comment.