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); }
public double calculateTotal(cart myShoppingCart) { double total = 0; foreach (var item in myShoppingCart.Items) { total += item.Item.Price * item.Quantity; } return(total); }
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); }
public double calculatePayment(cart MyShoppingCart) { double bills = calTotal.calculateTotal(MyShoppingCart) + calTaxes.calculateTaxes(MyShoppingCart) - calDiscount.calculateDiscount(MyShoppingCart); return(bills * exRate.ExchangeCurrency(MyShoppingCart.Currency)); }
public void AddDiscount(cart MyShoppingCart, discount discount) { throw new NotImplementedException(); }
public List <cartItem> GetItems(cart MyShoppingCart) { return(MyShoppingCart.Items); }
public void AddItem(cart MyShoppingCart, cartItem item) { MyShoppingCart.Items.Add(item); }