Пример #1
0
        public double calculateDiscount(cart MyShoppingCart)
        {
            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(MyShoppingCart) * 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);
        }
Пример #2
0
        public double calculateTotal(cart myShoppingCart)
        {
            double total = 0;

            foreach (var item in myShoppingCart.Items)
            {
                total += item.Item.Price * item.Quantity;
            }
            return(total);
        }
Пример #3
0
        public double calculateTaxes(cart MyShoppingCart)
        {
            double taxes = 0;

            foreach (var item in MyShoppingCart.Items)
            {
                taxes += item.Item.Price * item.Item.Taxe * item.Quantity;
            }
            return(taxes);
        }
Пример #4
0
        public double calculatePayment(cart MyShoppingCart)
        {
            double bills = calTotal.calculateTotal(MyShoppingCart) + calTaxes.calculateTaxes(MyShoppingCart) - calDiscount.calculateDiscount(MyShoppingCart);

            return(bills * exRate.ExchangeCurrency(MyShoppingCart.Currency));
        }
Пример #5
0
 public void AddDiscount(cart MyShoppingCart, discount discount)
 {
     throw new NotImplementedException();
 }
Пример #6
0
 public List <cartItem> GetItems(cart MyShoppingCart)
 {
     return(MyShoppingCart.Items);
 }
Пример #7
0
 public void AddItem(cart MyShoppingCart, cartItem item)
 {
     MyShoppingCart.Items.Add(item);
 }