Esempio n. 1
0
        /// <summary>
        /// 删除当前会话下的购物车商品
        /// </summary>
        /// <param name="cartProductId">购物车商品Id</param>
        /// <returns></returns>
        public virtual bool DeleteCartProduct(long cartProductId)
        {
            // 从数据库删除,只删除当前会话下的购物车商品
            var  sessionManager = Application.Ioc.Resolve <SessionManager>();
            bool result         = UnitOfWork.WriteRepository <CartProductRepository, bool>(r => {
                var cartProduct = r.GetManyBySession(sessionManager.GetSession(), null)
                                  .FirstOrDefault(c => c.Id == cartProductId);
                if (cartProduct != null)
                {
                    r.Delete(cartProduct);
                    return(true);
                }
                return(false);
            });

            // 删除相关的缓存
            CartProductTotalCountCache.Clear();
            return(result);
        }
 /// <summary>
 /// 清理缓存
 /// </summary>
 public void ClearCache()
 {
     CartProductTotalCountCache.Clear();
 }