Ejemplo n.º 1
0
        public double CalculateDiscount()
        {
            double discount = 0;

            foreach (var Discount in myShoppingCart.Discounts)
            {
                if (Discount.Type == DiscountType.noDiscount)
                {
                    discount += 0.0;
                }

                if (Discount.Type == DiscountType.perCart)
                {
                    discount += calTotal.CalculateTotal() * Discount.Percentage;
                }

                foreach (var item in myShoppingCart.Items)
                {
                    if (Discount.Type == DiscountType.perItem && item.HasDiscount)
                    {
                        discount += item.Item.Price * item.Discount * item.Quantity;
                    }
                    else if (Discount.Type == DiscountType.perType && item.HasDiscount)
                    {
                        discount += item.Item.Price * item.Discount;
                    }
                }
            }
            return(discount);
        }
Ejemplo n.º 2
0
        public double payment()
        {
            double bills = calTotal.CalculateTotal() + calTaxes.CalculateTaxes() - calDiscount.CalculateDiscount();

            return(bills * exRate.ExchangeCurrency(myShoppingCart.Currency));
        }