User1692641958 posted
Hello, I'm currently doing a web service rest, in which I have a method that returns two variables and if one of those varibles is empty or null execute a different method by passing the variable that is not empty or null.
Here the method that returns two variables:
PER_CON_CODIGO, PER_CON_SIGUIENTE_PERFIL, if PER_CON_SIGUIENTE_PERFIL is null or empty, execute a method to obtain obtenerPerfilesByContinuidad passing it the PER_CON_CODIGO that obtains from the method to obtenerPerfilContinuidad.
Method obtenerPerfilContinuidad:
public LaboratorioPerfil obtenerPerfilContinuidad(string id)
{
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conexion"].ToString()))
{
StringBuilder errorMessages = new StringBuilder();
LaboratorioPerfil lab = new LaboratorioPerfil();
try
{
cn.Open();
SqlCommand cmd = new SqlCommand("opGlobal.SP_SEL_CONTINUIDAD_CONTINUACION_BY_PERFIL", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PERFIL", id);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
lab.PER_CON_CODIGO = dr.GetString(0);
lab.PER_CON_SIGUIENTE_PERFIL = dr.GetString(0);
}
return lab;
}
catch (SqlException ex)
{
return null;
}
finally
{
cn.Close();
}
}
}
|
Here the method that I want to execute after
Method obtenerPerfilesByContinuidad:
public LaboratorioContinuidad obtenerPerfilesByContinuidad(string continuidad)
{
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conexion"].ToString()))
{
LaboratorioContinuidad lab = new LaboratorioContinuidad();
try
{
cn.Open();
SqlCommand cmd = new SqlCommand("opGlobal.SP_SEL_PERFILES_BY_CONTINUIDAD", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@CONTINUIDAD", continuidad);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
lab.PER_CON_PRUEBAS_BASICAS = dr.GetString(0);
}
return lab;
}
catch (Exception)
{
return null;
}
finally
{
cn.Close();
}
}
}
|