Example #1
0
 public CartItem(Product product)
 {
     this.cartProduct = product;
     cartOrderLine = new OrderLine()
     {
         ProductID = product.ProductID,
         Quantity = 1,
         Price = Price
     };
 }
 public SalesDealContainer(SalesCombination salesCombination, Product mainProduct, Product subProduct)
 {
     this.SalesCombination = salesCombination;
     this.MainProduct = mainProduct;
     this.SubProduct = subProduct;
 }
        private async void LoadBundleDeals(Product productDealToFind)
        {
            salesComboDeals.Clear();
            if (productDealToFind == null)
                return;

            var deals = await webService.GetSalesCombinations(productDealToFind.ProductID);

            foreach (var deal in deals)
            {
                Product subProduct = await getProduct(deal.SubProductID);
                if (subProduct == null) //If the product doesnt exist, the deal cannot exist
                {
                    logger.Warn(string.Format("Product deal [{0}] exists without valid sub-product [{1}]", deal.SalesCombinationID, deal.SubProductID));
                    return;
                }

                SalesComboDeals.Add(new SalesDealContainer(deal, productDealToFind, subProduct));
            }
        }
        public void OnAddToCart(Product productToAdd)
        {
            var existingBasket = MyCart.FirstOrDefault(s => s.cartProduct != null && s.cartProduct.ProductID == productToAdd.ProductID);

            if (existingBasket != null)
                existingBasket.AddOne();
            else
                MyCart.Add(new CartItem(productToAdd));

            CartCount = MyCart.Sum(s => s.cartOrderLine.Quantity);
            CartCost = MyCart.Sum(s => s.cartOrderLine.Price);
        }