Condiciones que se cumplen en un IF

4 views
Skip to first unread message

Carlos Admirador

unread,
Aug 6, 2021, 4:20:53 AM8/6/21
to AltNet-Hispano
Tengo este código, donde hay muchas condiciones (abreviado para el código) en un if.Muestro las condiciones que se cumplen en un string (causas)

 var datosCliente = EncuestaX.ObtenerDatosArchivoClientePorIndice(ind);
if (datosCliente == null
|| datosCliente.TipoGestion != ConfigX.TipoEncuestaDescripcion_Email
|| datosCliente.Agente != agenteCodigo
|| !datosCliente.FechaFin.HasValue)
{
var causas = "";
if (datosCliente == null) causas += $" No hay datos para el indice {ind}";
if (datosCliente.TipoGestion != ConfigX.TipoEncuestaDescripcion_Email) causas += $" {datosCliente.TipoGestion} no es Email";
if (datosCliente.Agente != agenteCodigo) causas += $" Agente {datosCliente.Agente} no es {agenteCodigo}";
if (!datosCliente.FechaFin.HasValue) causas += $" FechaFin sin valor";
TratarExcepcion("Datos incorrectos. Indice: " + ind + " - Causas: " + causas);
return;
}


Alguna forma mejor de hacerlo? 

Carlos Admirador

unread,
Sep 12, 2022, 2:20:52 AM9/12/22
to AltNet-Hispano
FluentAssertions o FluentValidation aplicaría para mejorar el código?
Reply all
Reply to author
Forward
0 new messages