public List <RecipeIngredientsModel> GetALLIngredients() { List <RecipeIngredientsModel> ingredients = new List <RecipeIngredientsModel>(); using var command = _connection.CreateCommand(); command.CommandText = "SELECT * FROM ingredients "; using var reader = command.ExecuteReader(); while (reader.Read()) { RecipeIngredientsModel ingredient = new RecipeIngredientsModel { IngredientID = (int)reader["ingredient_id"], IngredientName = (string)reader["ingredient_name"], }; ingredients.Add(ingredient); } return(ingredients); }
public List <RecipeIngredientsModel> GetShoppingList(int userID) { List <RecipeIngredientsModel> Ingredients = new List <RecipeIngredientsModel>(); using var command = _connection.CreateCommand(); command.CommandText = $"SELECT * FROM ingredients WHERE ingredient_id in" + $"(SELECT ingredient_id FROM shopping_list WHERE user_id = {userID})"; using var reader = command.ExecuteReader(); while (reader.Read()) { RecipeIngredientsModel ingredient = new RecipeIngredientsModel { IngredientID = (int)reader["ingredient_id"], IngredientName = (string)reader["ingredient_name"] }; Ingredients.Add(ingredient); } return(Ingredients); }