public decimal returnIngredientMeasuredPrice(Ingredient i) { var db = new DatabaseAccess(); var myIngredient = db.queryAllRelevantTablesSQLByIngredientName(i); return(MeasuredIngredientPrice(myIngredient)); }
//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); }
public void getIngredientMeasuredPrice(Ingredient i, Recipe r) { var db = new DatabaseAccess(); db.queryAllRelevantTablesSQLByIngredientName(i); i.priceOfMeasuredConsumption = MeasuredIngredientPrice(i); UpdateIngredient(i); }
public List <Ingredient> myIngredientBox() { var db = new DatabaseAccess(); var ingredientBox = new List <Ingredient>(); var queriedIngredients = queryAllIngredientsFromIngredientTable(); foreach (var ingredient in queriedIngredients) { ingredientBox.Add(db.queryAllRelevantTablesSQLByIngredientName(ingredient)); } return(ingredientBox); }
public void subtractOuncesRemainingIfExpirationDateIsPast(Ingredient i) { var db = new DatabaseAccess(); var dbIngredients = new DatabaseAccessIngredient(); var convert = new ConvertWeight(); var myIngredient = db.queryAllRelevantTablesSQLByIngredientName(i); if (i.expirationDate < DateTime.Today && (dbIngredients.convertDateToStringMMDDYYYY(i.expirationDate) != "01/01/0001")) { myIngredient.ouncesRemaining = myIngredient.ouncesRemaining - i.sellingWeightInOunces; if (myIngredient.ouncesRemaining < 0m) { myIngredient.ouncesRemaining = 0m; } var commandText = @"update consumption set ounces_remaining=@ounces_remaining where name=@name"; db.executeVoidQuery(commandText, cmd => { cmd.Parameters.AddWithValue("@name", myIngredient.name); cmd.Parameters.AddWithValue("@ounces_remaining", i.ouncesRemaining); return(cmd); }); } var myUpdatedIngredient = queryConsumptionTable(); }