Esempio n. 1
0
 /// <summary>
 /// Gets a collection of basket items in this basket shipment from the given basket
 /// </summary>
 /// <param name="basket">The basket object</param>
 /// <returns>A collection of basket items in this basket shipment</returns>
 public BasketItemCollection GetItems(Basket basket)
 {
     List<BasketItem> itemList = basket.Items.FindAll(delegate(BasketItem item) { return (item.BasketShipmentId.Equals(this.BasketShipmentId)); });            
     BasketItemCollection items = new BasketItemCollection();
     items.AddRange(itemList);
     return items;
 }
Esempio n. 2
0
        /// <summary>
        /// Gets a collection of items represented by this shipment
        /// </summary>
        /// <returns></returns>
        public BasketItemCollection GetItems()
        {
            BasketItemCollection items = new BasketItemCollection();

            if (this.Order != null)
            {
                foreach (OrderItem item in this.Order.Items)
                {
                    items.Add(item.GetBasketItem());
                }
            }
            return(items);
        }
        /// <summary>
        /// Get the child items of the given basket item.
        /// </summary>
        /// <param name="basketItem">BasketItem to get the child items for</param>
        /// <param name="orderItemTypes">Type of order item objects to include</param>
        /// <returns>A collection of child items of the given basket item</returns>
        public BasketItemCollection GetChildItems(BasketItem basketItem, params OrderItemType[] orderItemTypes)
        {
            BasketItemCollection childProducts = new BasketItemCollection();

            foreach (BasketItem item in this)
            {
                if (item.IsChildItem && item.ParentItemId == basketItem.BasketItemId &&
                    Array.IndexOf(orderItemTypes, item.OrderItemType) > -1)
                {
                    childProducts.Add(item);
                }
            }
            return(childProducts);
        }
Esempio n. 4
0
        private static short GetExistingBasketCount(Product product)
        {
            BasketItemCollection items = Token.Instance.User.Basket.Items;

            foreach (BasketItem item in items)
            {
                if (item.ProductId == product.ProductId)
                {
                    return(item.Quantity);
                }
            }
            // no item found
            return(0);
        }
Esempio n. 5
0
 /// <summary>
 /// Delete this basket shipment object from database
 /// </summary>
 /// <returns><b>true</b> if delete successful, <b>false</b> otherwise</returns>
 public virtual bool Delete()
 {
     //DELETE ANY BASKET ITEMS IN THIS SHIPMENT 
     BasketItemCollection itemCollection = this.Basket.Items;
     for (int i = (itemCollection.Count - 1); i >= 0; i--)
     {
         BasketItem item = itemCollection[i];
         if (item.BasketShipmentId.Equals(this.BasketShipmentId))
         {
             itemCollection.DeleteAt(i);
         }
     }
     return this.BaseDelete();
 }
Esempio n. 6
0
 /// <summary>
 /// Apply a ship method to this basket shipment
 /// </summary>
 /// <param name="shipMethod">The ship method to apply</param>
 public void ApplyShipMethod(ShipMethod shipMethod)
 {
     if (shipMethod == null) throw new ArgumentNullException("shipMethod");
     //WIPE OUT ANY SHIPPING CHARGES CURRENTLY IN THIS SHIPMENT
     this.ShipMethodId = shipMethod.ShipMethodId;
     this._ShipMethod = shipMethod;
     BasketItem item;
     BasketItemCollection basketItems = this.Basket.Items;
     for (int i = basketItems.Count - 1; i >= 0; i--)
     {
         item = basketItems[i];
         if (item.BasketShipmentId.Equals(this.BasketShipmentId) && ((item.OrderItemType == OrderItemType.Shipping || item.OrderItemType == OrderItemType.Handling)))
         {
             basketItems.DeleteAt(i);
         }
     }
     ShipRateQuote quote = shipMethod.GetShipRateQuote(this);
     if (quote == null) throw new ArgumentException("The specified shipping method is not valid for these items.", "shipMethod");
     item = new BasketItem();
     item.BasketId = this.BasketId;
     item.BasketShipmentId = this.BasketShipmentId;
     item.Name = quote.ShipMethod.Name;
     item.OrderItemType = OrderItemType.Shipping;
     item.Price = quote.Rate;
     item.Weight = 0;
     item.Quantity = 1;
     basketItems.Add(item);
     if (quote.Surcharge > 0)
     {
         item = new BasketItem();
         item.BasketId = this.BasketId;
         item.BasketShipmentId = this.BasketShipmentId;
         item.Name = quote.ShipMethod.Name;
         item.OrderItemType = OrderItemType.Handling;
         item.Price = quote.Surcharge;
         item.Weight = 0;
         item.Quantity = 1;
         basketItems.Add(item);
     }
     basketItems.Save();
     this.Save();
 }