public RecipeManager(string DatabaseToUse, ProgramManager Manager) { RecipeDatabaseFile = DatabaseToUse; CurrentManager = Manager; UserIndex = Manager.User.CompatabilityIndex; Recipies = GetRecipies(); FridgeItems = Manager.UsersFridge.USUsersFoods; SortRecipes(); }
public UserTemplate(ProgramManager Manager) { CurrentManager = Manager; CompatabilityIndex = 0; CalculateIndex(); }
/// <summary> /// After using a certian product changes the Amount left, or if the AmountToChange is 0 removes the Item /// </summary> /// <param name="FoodItemToChange"></param> /// <param name="AmountToChange"></param> public void ModifyFoodItemAmount(List <string> FoodItemsToChange, List <float> AmountsToChange, List <string> Units, FoodManager foodManager, ProgramManager programManager) { for (int i = 0; i < FoodItemsToChange.Count; i++) { float AmountToRemove = UnitConverter.GetAmountToRemove(FoodItemsToChange[i], AmountsToChange[i], Units[i], foodManager); foreach (KeyValuePair <string, FoodDef> element in USUsersFoods) { if (element.Value.USName.ToLower() == FoodItemsToChange[i].ToLower() && element.Value.Amount - AmountToRemove >= 0) { element.Value.Amount -= AmountToRemove; } } } for (int i = 0; i < USUsersFoods.Count; i++) { if (USUsersFoods.ElementAt(i).Value.Amount == 0) { if (!programManager.UserShoppingList.USFoodsToBuy.Contains(FoodItemsToChange[i])) { programManager.UserShoppingList.AddToShoppingList(USUsersFoods.ElementAt(i).Value.USName, USUsersFoods.ElementAt(i).Value.BGName); } USUsersFoods.Remove(USUsersFoods.ElementAt(i).Key); } } SaveFridge(); programManager.SaveShoppingList(); }
public void AddToShoppingList(List <string> FoodItemsToChange, List <float> AmountsToChange, List <string> Units, FoodManager foodManager, ProgramManager programManager) { if (FoodItemsToChange != null) { for (int i = 0; i < FoodItemsToChange.Count; i++) { float AmountToRemove = UnitConverter.GetAmountToRemove(FoodItemsToChange[i], AmountsToChange[i], Units[i], foodManager); if (USUsersFoods.ContainsKey(FoodItemsToChange[i])) { foreach (KeyValuePair <string, FoodDef> element in USUsersFoods) { if (element.Value.USName == FoodItemsToChange[i] && element.Value.Amount - AmountToRemove < 0) { if (!programManager.UserShoppingList.USFoodsToBuy.Contains(FoodItemsToChange[i])) { programManager.UserShoppingList.AddToShoppingList(element.Value.USName, element.Value.BGName); } } } } else { if (!programManager.UserShoppingList.USFoodsToBuy.Contains(FoodItemsToChange[i])) { programManager.UserShoppingList.AddToShoppingList(FoodItemsToChange[i], foodManager.Foods[FoodItemsToChange[i]].BGName); } } } programManager.SaveShoppingList(); } // Only if requirements are met does the function return true. }
/// <summary> /// Takes a string array, loops through the array checknig if the fridge dictionary contains such a key. /// If it doesn't contain even one item it breaks the loop and returns false. /// </summary> /// <param name="foods"></param> /// <returns></returns> public bool FridgeConatains(List <string> FoodItemsToChange, List <float> AmountsToChange, List <string> Units, FoodManager foodManager, ProgramManager programManager) { if (FoodItemsToChange != null) { for (int i = 0; i < FoodItemsToChange.Count; i++) { float AmountToRemove = UnitConverter.GetAmountToRemove(FoodItemsToChange[i], AmountsToChange[i], Units[i], foodManager); if (USUsersFoods.ContainsKey(FoodItemsToChange[i])) { foreach (KeyValuePair <string, FoodDef> element in USUsersFoods) { if (element.Value.USName == FoodItemsToChange[i] && element.Value.Amount - AmountToRemove < 0) { return(false); } } } else { return(false); } } } // Only if requirements are met does the function return true. return(true); }