public IEnumerable <EtiquetaModel> BuscaTodasEtiquetas() { List <EtiquetaModel> myModel = new List <EtiquetaModel>(); using (SqlConnection connection = new SqlConnection(connectionString)) using (SqlCommand command = new SqlCommand("", connection)) { connection.Open(); command.CommandText = "EXEC ETIQUETAS_SEL @ACCION"; command.Parameters.AddWithValue("@ACCION", 4); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { EtiquetaModel model = new EtiquetaModel(); model.aor_id = (int)reader["aor_id"]; model.nombre_area = (string)reader["area"]; model.eti_id = (int)reader["eti_id"]; model.nombre_etiqueta = (string)reader["etiqueta"]; model.descripcion = (string)reader["descripcion"]; model.causa = (string)reader["causa"]; model.solucion = (string)reader["solucion"]; myModel.Add(model); } reader.Close(); connection.Close(); } return(myModel); }
public EtiquetaModel BuscaEtiquetaPorEti(int eti) { var model = new EtiquetaModel(); using (SqlConnection connection = new SqlConnection(connectionString)) using (SqlCommand command = new SqlCommand("", connection)) { connection.Open(); command.CommandText = "EXEC ETIQUETAS_SEL @ACCION, @ETI"; command.Parameters.AddWithValue("@ACCION", 1); command.Parameters.AddWithValue("@ETI", eti); SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { model.eti_id = (int)reader["eti_id"]; model.nombre_etiqueta = (string)reader["etiqueta"]; model.descripcion = (string)reader["descripcion"]; model.causa = (string)reader["causa"]; model.solucion = (string)reader["solucion"]; } reader.Close(); connection.Close(); } return(model); }