Ejemplo n.º 1
0
        /// <summary>
        /// 删除购物车中的商品信息
        /// </summary>
        /// <param name="shoppingCartId">购物车ID</param>
        /// <returns></returns>
        public bool DeleteShoppingCartByProductIdUserID(int shoppingCartId)
        {
            var holycaDb = new HolycaEntities();

            Sale_ShoppingCart queryTxt = holycaDb.Sale_ShoppingCart.Where(c => c.intShopCartID == shoppingCartId).FirstOrDefault();

            holycaDb.DeleteObject(queryTxt);

            holycaDb.SaveChanges();

            return true;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 清除购物车数据
 /// </summary>
 /// <param name="userId"></param>
 public void ClearShoppingCart(int userId)
 {
     using (var db = new HolycaEntities())
     {
         var queryTxt = from a in db.Sale_ShoppingCart
                        where a.intUserID == userId
                        select a;
         var shoppingCartList = queryTxt.ToList();
         foreach (var saleShoppingCart in shoppingCartList)
         {
             db.Sale_ShoppingCart.DeleteObject(saleShoppingCart);
         }
         db.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 增加购物车商品信息
 /// </summary>
 /// <param name="shoppingCartEntity">购物车信息实体</param>
 /// <returns></returns>
 public bool AddShoppingCartProductInfo(ShoppingCartEntity shoppingCartEntity)
 {
     var holycaDb = new HolycaEntities();
     Sale_ShoppingCart sale_ShoppingCart = new Sale_ShoppingCart();
     MCvHelper.ObjectCopyTo(shoppingCartEntity, sale_ShoppingCart);
     try
     {
         holycaDb.Sale_ShoppingCart.AddObject(sale_ShoppingCart);
         holycaDb.SaveChanges();
         return true;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 设置购物车商品数量
 /// </summary>
 /// <param name="user_id"></param>
 /// <param name="guid"></param>
 /// <param name="shoppingCartId"></param>
 /// <param name="num"></param>
 /// <returns></returns>
 public bool SetShoppingCartGoodsNum(int user_id, string guid, int shoppingCartId, int num)
 {
     var result = false;
     if (num > 0)
     {
         using (var holycaDb = new HolycaEntities())
         {
             var shoppingCartEntity = holycaDb.Sale_ShoppingCart.First(s => s.intShopCartID == shoppingCartId);
             if (shoppingCartEntity != null)
             {
                 try
                 {
                     shoppingCartEntity.intBuyCount = num;
                     holycaDb.SaveChanges();
                     result = true;
                 }
                 catch (Exception)
                 {
                     holycaDb.Refresh(RefreshMode.ClientWins, shoppingCartEntity);
                     holycaDb.SaveChanges();
                     result = false;
                 }
             }
         }
     }
     return result;
 }