Пример #1
0
        public void StoreIngredient(IngredientAmount ingredient)
        {
            /* Find ingredient in store */
            IngredientAmount storeIngredient = FindOrInsertIngredient(ingredient.Ingredient);

            //storeIngredient.Value += value;
        }
Пример #2
0
        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);
        }
Пример #3
0
        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.");
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
        public void TakeIngredient(IngredientAmount ingredient)
        {
            IngredientAmount storeIngredient = FindOrInsertIngredient(ingredient.Ingredient);

            //storeIngredient.Value -= value;
        }