Ejemplo n.º 1
0
        public void Add(HttpContext ctx, int partID = 0, int quantity = 1) {
            if (this.payment_id == 0) {
                APIPart part = CURTAPI.GetPart(partID);
                string upcval = part.attributes.Where(x => x.key.ToLower().Equals("upc")).Select(x => x.value).FirstOrDefault();
                string weight = part.attributes.Where(x => x.key.ToLower().Equals("weight")).Select(x => x.value).FirstOrDefault();
                CartItem i = new CartItem(partID, quantity, Convert.ToDecimal(part.listPrice.Replace("$", "")), part.shortDesc, upcval, Convert.ToDecimal(weight));

                EcommercePlatformDataContext db = new EcommercePlatformDataContext();
                try {
                    CartItem item = db.CartItems.Where(x => x.partID == partID).Where(x => x.order_id == this.ID).First<CartItem>();
                    item.quantity += quantity;
                } catch {
                    i.order_id = this.ID;
                    db.CartItems.InsertOnSubmit(i);
                };
                db.SubmitChanges();
                clearShippingType();
            } else {
                UDF.ExpireCart(ctx,this.cust_id);
            }
        }
 partial void DeleteCartItem(CartItem instance);
 partial void UpdateCartItem(CartItem instance);
 partial void InsertCartItem(CartItem instance);
		private void detach_CartItems(CartItem entity)
		{
			this.SendPropertyChanging();
			entity.Cart = null;
		}
		private void attach_CartItems(CartItem entity)
		{
			this.SendPropertyChanging();
			entity.Cart = this;
		}