//更新商品信息 public ActionResult UpdateGoodsCallBack(AddGoodsCallBackIn InModel) { string errorType = ""; string msg = "OK"; Model.GoodsBaseInfo goodsInfo = new Model.GoodsBaseInfo() { ID = InModel.ID, GoodsName = InModel.GoodsName, Price = InModel.Price, Describe = InModel.Describe, Category = InModel.Category, ShowIcons = string.IsNullOrEmpty(InModel.ShowIcons) ? "" : InModel.ShowIcons.Remove(InModel.ShowIcons.Length - 1), DetailIcons = string.IsNullOrEmpty(InModel.DetailIcons) ? "" : InModel.DetailIcons.Remove(InModel.DetailIcons.Length - 1), CreateUserID = Identity.LoginUserInfo.UserID.ToString(), CreateTime = DateTime.Now.ToString() }; bool result = BLL.GoodsBaseInfoBll.UpDateGoodsInfo(goodsInfo); if (!result) { errorType = "alert"; msg = "添加失败,请重试"; } return(Json(new { Message = msg, ErrorType = errorType }, JsonRequestBehavior.AllowGet)); }
//添加商品信息 public ActionResult AddGoodsCallBack(AddGoodsCallBackIn InModel) { string errorType = ""; string msg = "OK"; //用来返回刚插入的记录的ID string insertID = ""; // 验证参数 if (string.IsNullOrWhiteSpace(InModel.GoodsName)) { errorType = "GoodsName"; msg = "请输入商品名称"; } else if (BLL.BackgroundUserBll.IsExistUserName(InModel.Describe)) { errorType = "Describe"; msg = "请输入商品详情"; } else if (string.IsNullOrWhiteSpace(InModel.Price)) { errorType = "Price"; msg = "请输入商品价格"; } else if (string.IsNullOrWhiteSpace(InModel.Category)) { errorType = "Category"; msg = "请选择商品类别"; } else { // 添加用户 Model.GoodsBaseInfo goodsInfo = new Model.GoodsBaseInfo() { GoodsName = InModel.GoodsName, Price = InModel.Price, Describe = InModel.Describe, Category = InModel.Category, CreateUserID = Identity.LoginUserInfo.UserID.ToString(), CreateTime = DateTime.Now.ToString() }; insertID = BLL.GoodsBaseInfoBll.AddGoodsInfo(goodsInfo); if (string.IsNullOrEmpty(insertID)) { errorType = "alert"; msg = "添加失败,请重试"; } } return(Json(new { Message = msg, ErrorType = errorType, InsertID = insertID }, JsonRequestBehavior.AllowGet)); }