//i need to rewrite the query to call a different () to get all the information for all the ingredients... i'm not getting an ing.id, densities... //only the name and the measurement public void UpdateRecipeYield(Recipe r) { var db = new DatabaseAccess(); var dbDensities = new DatabaseAccessDensityInformation(); var convert = new ConvertMeasurement(); var myRecipeBox = MyRecipeBox(); foreach (var recipe in myRecipeBox) { var myIngredients = db.queryAllTablesForAllIngredients(recipe.ingredients); var tempIngredient = new Ingredient(); if (recipe.id == r.id) { foreach (var ingredient in recipe.ingredients) { tempIngredient = ingredient; if (tempIngredient.density == 0) { tempIngredient.density = dbDensities.queryDensityTableRowDensityValueByName(ingredient); } tempIngredient.measurement = convert.AdjustIngredientMeasurement(ingredient.measurement, recipe.yield, r.yield); tempIngredient.ouncesConsumed = ingredient.ouncesConsumed * (HomeController.currentRecipe.yield / r.yield); db.updateAllTables(tempIngredient, r); var myUpdatedIngredient = db.queryAllRelevantTablesSQLByIngredientName(tempIngredient); } recipe.yield = r.yield; GetFullRecipePrice(recipe); var myUpdatedIngredients = db.queryAllTablesForAllIngredients(recipe.ingredients); } } }
public void GetFullRecipePrice(Recipe r) { var db = new DatabaseAccess(); var dbIngredients = new DatabaseAccessIngredient(); var myIngredients = GetFullRecipeAndFullIngredientsForRecipe(r).ingredients; foreach (var ing in myIngredients) { if (ing.recipeId == r.id) { dbIngredients.getIngredientMeasuredPrice(ing, r); r.ingredients.Add(ing); db.updateAllTables(ing, r); var currentIngredient = db.queryAllRelevantTablesSQLByIngredientName(ing); } } var aggregatedPrice = 0m; foreach (var ing in r.ingredients) { aggregatedPrice += ing.priceOfMeasuredConsumption; } r.aggregatedPrice = aggregatedPrice; UpdateRecipe(r); }