Ejemplo n.º 1
0
 private void CallBack(IAsyncResult ar)
 {
     try
     {
         DelGoodsCategoryDel del = (DelGoodsCategoryDel)ar.AsyncState;
         del.EndInvoke(ar);
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 2
0
        public ActionResult Delete(string GoodsCode)
        {
            if (string.IsNullOrEmpty(GoodsCode))
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }

            Goods goods = _goodsBLL.GetGoodsByCode(GoodsCode);

            if (goods == null)
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }

            goods.IsDeleted   = true;
            goods.DeletedTime = DateTime.Now;

            if (_goodsBLL.Update(goods))
            {
                // 删除商品图片
                GoodsImage gi = _goodsImagesBLL.GetPictureByGoodsId(goods.Id);
                gi.IsDeleted   = true;
                gi.DeletedTime = DateTime.Now;

                _goodsImagesBLL.Update(gi);

                // 获取商品分类列表
                List <GoodsCategory> gcList = _goodsCategoryBLL.GetGoodsCategoryListByGoodsId(goods.Id).ToList();

                // 异步删除商品分类列表
                DelGoodsCategoryDel del    = new DelGoodsCategoryDel(DeleteGoodsCategory);
                IAsyncResult        result = del.BeginInvoke(gcList, CallBack, null);

                return(Json("True", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("False", JsonRequestBehavior.AllowGet));
            }
        }