Ejemplo n.º 1
0
        public void InsertDetailsFromCart(ORDERS Order, List <SHOPPING_CART> Cart, bool Attach = true)
        {
            if (Cart != null && Cart.Count > 0)
            {
                ORDER_DETAIL detail;
                foreach (SHOPPING_CART item in Cart)
                {
                    detail            = new ORDER_DETAIL();
                    detail.OrderID    = Order.ID;
                    detail.CampaignID = item.CampaignID;
                    detail.ProdAttrID = item.ProdAttrID;
                    detail.Quantity   = item.Quantity;

                    // first insert order
                    _orderDAO.InsertDetail(detail);

                    item.CAMPAIGN          = null;
                    item.CUSTOMER          = null;
                    item.PRODUCT_ATTRIBUTE = null;

                    //second remove the related cart item
                    _cartDAO.Delete(item, Attach);
                }
                Context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void Delete(SHOPPING_CART Entity)
        {
            // first "put back" the product that was in cart
            // version is not needed as the availability is incremented, so no risk
            PRODUCT_ATTRIBUTE prodAttr = _productDAO.GetProductAttributeById(Entity.ProdAttrID);

            prodAttr.Availability += Entity.Quantity;
            _productDAO.UpdateProductAttribute(prodAttr, false);

            // second remove item from cart
            _shoppingCartDAO.Delete(Entity, false);

            // then save if everything was successful
            Context.SaveChanges();
        }