示例#1
0
        public JsonResult Delete(int id)
        {
            var jsonSuccessResult = new JsonSuccessResult();

            try
            {
                var cartItems = CartItems.CountByProductID(id);
                var gifts     = ProductGifts.CountByProductID(id);

                if (cartItems == 0 && gifts == 0)
                {
                    Products.Delete(id);
                    jsonSuccessResult.Success = true;
                }

                jsonSuccessResult.Success = false;
            }
            catch (Exception ex)
            {
                jsonSuccessResult.Errors  = new string[] { ex.Message };
                jsonSuccessResult.Success = false;
            }

            return(new JsonResult()
            {
                Data = jsonSuccessResult
            });
        }