Пример #1
0
        public JsonResult SaveProduct(string productInfo, bool isRelease, string action)
        {
            var result = string.Empty;

            try
            {
                var product = JsonHelper.ToObject <ProductJsonModel>(productInfo);

                if (action == "edit")
                {
                    result = bll.SaveReleasedProduct(product, CurrentUser.SupplierID, CurrentUser.UserID);
                }
                else
                {
                    result = bll.SaveUnreleasedProduct(product, CurrentUser.SupplierID, CurrentUser.UserID, isRelease);
                }

                bll.SaveProductJson(result, productInfo, isRelease.ToString(), action);

                if (string.IsNullOrEmpty(result))
                {
                    return(Json(new { data = 0, msg = "保存失败" }));
                }
                else
                {
                    if (isRelease)
                    {
                        bll.UpdateCategoryHistory(CurrentUser.SupplierID, product.SPU.CategoryId);
                    }
                    return(Json(new { data = 1, msg = "保存成功", Spu = result }));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(Json(new { data = 0, msg = "保存失败" }));
            }
        }