コード例 #1
0
        // This is instead of the RemoveProduct method in the specification
        protected override void RemoveItem(int index)
        {
            BasketItem item = base.Items[index];

            if (item.Offer != null)
            {
                item.Offer.Products.Remove(item.ProductID);
                item.Offer.Quantity -= item.Quantity;
                OfferList.Remove(item);
            }

            base.RemoveItem(index);
        }
コード例 #2
0
 // This is instead of the ClearBasket method in the specification
 protected override void ClearItems()
 {
     foreach (BasketItem item in base.Items)
     {
         if (item.Offer != null)
         {
             item.Offer.Products.Remove(item.ProductID);
             item.Offer.Quantity -= item.Quantity;
             OfferList.Clear();
         }
     }
     base.ClearItems();
 }
コード例 #3
0
 // This is instead of the AddProduct method in the specification
 protected override void InsertItem(int index, BasketItem item)
 {
     // If the Keyed Collection already has the product
     // then just increment its quantity
     if (this.Contains(item.ProductID))
     {
         this[item.ProductID].Quantity += item.Quantity;
         OfferList.Add(item);
         OfferList.CalculateOffers(this);
     }
     else
     {
         base.InsertItem(index, item);
         OfferList.Add(item);
         OfferList.CalculateOffers(this);
     }
 }