public List <MostrarIngredientes> ListarInformacoesIngredientes(MostrarIngredientes mostrarIngredientes) { try { return(repositorioIngredientes.GetInfoIngredientes(mostrarIngredientes)); } catch (Exception e) { throw; } }
internal List <MostrarIngredientes> GetInfoIngredientes(MostrarIngredientes mostrarIngredientes) { try { using (SQLiteConnection connection = new SQLiteConnection(sqlitecon)) { connection.Open(); string query = string.Format("SELECT ID, NOME, GRANDEZA FROM INGREDIENTES WHERE ID = @ID"); List <MostrarIngredientes> retorno = new List <MostrarIngredientes>(); using (SQLiteCommand cmd = new SQLiteCommand(query, connection)) { cmd.Parameters.AddWithValue("@ID", mostrarIngredientes.Id); SQLiteDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { MostrarIngredientes aux = new MostrarIngredientes() { Id = Convert.ToInt32(dr["ID"]), Nome = dr["NOME"].ToString(), Grandeza = dr["GRANDEZA"].ToString() }; retorno.Add(aux); } return(retorno.Count > 0 ? retorno : null); } } } catch (SQLiteException e) { throw; } }