= Database Connection =
 .type:: `sqlite`
 .file:: `attachment:Recipes.db`


= Recipe Form =
 recipe.select:: `select * from Recipes where IFNULL(Name, '') like ('%' || IFNULL(?, '') || '%') and IFNULL(Category, '') like ('%' || IFNULL(?, '') || '%') and (Energy ISNULL or Energy > IFNULL(?, 0) and Energy < IFNULL(?, 1000000)) and (Time ISNULL or Time > IFNULL(?, 0) and Time < IFNULL(?, 1000000)) and (Difficulty ISNULL or Difficulty > IFNULL(?, 0) and Difficulty < IFNULL(?, 1000000)) and IFNULL(Procedure, '') like ('%' || IFNULL(?, '') || '%') order by Name`

 recipe.select_parameters:: `.@Name, .@Category, .@MinEnergy, .@MaxEnergy, .@MinTime, .@MaxTime, .@MinDifficulty, .@MaxDifficulty, .@Procedure`

 recipe.update:: `update Recipes set Name=?, Category=?, Servings=?, Energy=?, Time=?, Difficulty=?, Procedure=? where Id=?`
 recipe.update_parameters:: `.Name, .Category, .Servings, .Energy, .Time, .Difficulty, .Procedure, .Id`

 recipe.insert:: `insert into Recipes(Name, Category, Servings, Energy, Time, Difficulty, Procedure) values(?, ?, ?, ?, ?, ?, ?)`
 recipe.insert_parameters:: `.Name, .Category, .Servings, .Energy, .Time, .Difficulty, .Procedure`

 recipe.delete:: `delete from Recipes where Id=?`
 recipe.delete_parameters:: `.Id`


= Ingredients of Recipe Form =
 ingredients_of_recipe.all:: 1
 ingredients_of_recipe.select:: `select * from Ingredients where RecipeId=? order by Ingredient`
 ingredients_of_recipe.select_parameters:: `.recipe.Id`

 ingredients_of_recipe.insert:: `insert into Ingredients(RecipeId, Quantity, Unit, Ingredient) values(?, ?, ?, ?)`
 ingredients_of_recipe.insert_parameters:: `.recipe.Id, .Quantity, .Unit, .Ingredient`

 ingredients_of_recipe.update:: `update Ingredients set RecipeId=?, Quantity=?, Unit=?, Ingredient=? where Id=?`
 ingredients_of_recipe.update_parameters:: `.recipe.Id, .Quantity, .Unit, .Ingredient, .Id`

 ingredients_of_recipe.delete:: `delete from Ingredients where Id=?`
 ingredients_of_recipe.delete_parameters:: `.Id`

 ingredients_of_recipe.header:: `|| '''Quantity''' || '''Unit''' || '''Ingredient''' || ||\n`
 ingredients_of_recipe.body:: `|| <<Form(Hidden, .Id)>><<Form(Text, .Quantity, 4)>> || <<Form(Text, .Unit, 10)>> || <<Form(Text, .Ingredient, 50)>>  || <<Form(Buttons)>><<Form(Next)>> ||\n`
