private void AddHopsIngredient(Hops hops)
        {
            HopsIngredientDataModel hopsIngredient = HopsUtility.CreateHopsIngredient(hops, CurrentRecipe.RecipeId);

            hopsIngredient.Amount           = m_settings.HopsAmount;
            hopsIngredient.PropertyChanged += CurrentRecipe.Ingredient_PropertyChanged;
            CurrentRecipe.HopsIngredients.Add(hopsIngredient);
        }
Example #2
0
 internal static void UpdateHopsIngredient(HopsIngredientDataModel hopsIngredient, SQLiteConnection connection)
 {
     using var updateCommand   = connection.CreateCommand();
     updateCommand.CommandText = "UPDATE HopsIngredients SET amount = @amount, time = @time, type = @type, form = @form, use = @use, dryHopTime = @dryHopTime WHERE id = @id";
     updateCommand.Parameters.AddWithValue("id", hopsIngredient.HopsId);
     updateCommand.Parameters.AddWithValue("amount", hopsIngredient.Amount);
     updateCommand.Parameters.AddWithValue("time", hopsIngredient.Time);
     updateCommand.Parameters.AddWithValue("type", hopsIngredient.FlavorType);
     updateCommand.Parameters.AddWithValue("form", hopsIngredient.Form);
     updateCommand.Parameters.AddWithValue("use", hopsIngredient.Use);
     updateCommand.Parameters.AddWithValue("dryHopTime", hopsIngredient.DryHopTime);
     updateCommand.ExecuteNonQuery();
 }
Example #3
0
        internal static HopsIngredientDataModel CreateHopsIngredient(Hops.Hops hopsInfo, int recipeId, SQLiteConnection connection)
        {
            using var insertCommand   = connection.CreateCommand();
            insertCommand.CommandText = "INSERT INTO HopsIngredients (amount, time, type, form, use, hopsInfo) VALUES(0, 0, 'Bittering', 'Leaf', 'Boil', (SELECT id FROM Hops WHERE name = @name))";
            insertCommand.Parameters.AddWithValue("name", hopsInfo.Name);
            insertCommand.ExecuteNonQuery();
            HopsIngredientDataModel hopsIngredient = new HopsIngredientDataModel(hopsInfo, DatabaseUtility.GetLastInsertedRowId(connection));

            using var insertJunctionCommand   = connection.CreateCommand();
            insertJunctionCommand.CommandText = "INSERT INTO HopsInRecipe (hopsIngredient, recipe) VALUES(@hopsIngredientId, @recipeId)";
            insertJunctionCommand.Parameters.AddWithValue("hopsIngredientId", hopsIngredient.HopsId);
            insertJunctionCommand.Parameters.AddWithValue("recipeId", recipeId);
            insertJunctionCommand.ExecuteNonQuery();
            return(hopsIngredient);
        }