public void StoreIngredient(IngredientAmount ingredient) { /* Find ingredient in store */ IngredientAmount storeIngredient = FindOrInsertIngredient(ingredient.Ingredient); //storeIngredient.Value += value; }
public void RemoveIngredient(Ingredient ingredient) { IngredientAmount ingr = Ingredients.FirstOrDefault(i => i.Ingredient.Id == ingredient.Id); if (ingr == null) { throw new Exception("Item is not present"); } Ingredients.Remove(ingr); }
public void AddIngredient(Ingredient ingredient, decimal amount) { IngredientAmount ingr = Ingredients.FirstOrDefault(i => i.Ingredient.Id == ingredient.Id); if (ingr == null) { ingr = new IngredientAmount(ingredient, amount); Ingredients.Add(ingr); } else { throw new Exception("Item is already present in the list of ingredients."); } }
private IngredientAmount FindOrInsertIngredient(Ingredient ingredient) { /* Find ingredient in store */ IngredientAmount storeIngredient = storeIngredients.FirstOrDefault( i => i.Ingredient.Id == ingredient.Id); if (storeIngredient == null) { /* Add new ingredient into the store */ storeIngredient = new IngredientAmount(ingredient); storeIngredients.Add(storeIngredient); } return(storeIngredient); }
public void TakeIngredient(IngredientAmount ingredient) { IngredientAmount storeIngredient = FindOrInsertIngredient(ingredient.Ingredient); //storeIngredient.Value -= value; }