示例#1
0
        public decimal Price(IList <ISale> sales)
        {
            var total = BurgerIngredients.Sum(toSum => toSum.Ingredient.Price * toSum.Qty);

            this.SaleDiscounts.Clear();

            for (int i = 0; sales != null && i < sales.Count; i++)
            {
                var sale         = sales[i];
                var saleDiscount = sale.SaleDiscount(this);

                total -= saleDiscount.Discount;

                this.SaleDiscounts.Add(saleDiscount);
            }

            return(total);
        }
示例#2
0
        public void SetIngredientQuantity(Ingredient ingredient, int qty)
        {
            var existingIngredient = BurgerIngredients.FirstOrDefault(type => type.Ingredient.IngredientType == ingredient.IngredientType);

            if (existingIngredient == null)
            {
                BurgerIngredients.Add(new BurgerIngredient()
                {
                    Ingredient = ingredient, Qty = qty
                });
            }
            else
            {
                BurgerIngredients.Remove(existingIngredient);
                BurgerIngredients.Add(new BurgerIngredient()
                {
                    Ingredient = ingredient, Qty = qty
                });
            }
        }