public ActionResult DeleteGoodsCategory(int id) { JsonModel jm = new JsonModel(); IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); //获取要删除的类别 T_GoodsCategory goodsCategory = goodsCategoryBll.GetEntity(m => m.Id == id); if (goodsCategory == null) { jm.Msg = "该类别不存在"; } else if (goodsCategory.ShopSales.Count() > 0) { jm.Msg = "已有该类型的商品,无法删除"; } else { if (goodsCategoryBll.Delete(goodsCategory)) { //操作日志 jm.Content = "删除商品类别 " + goodsCategory.Name; } else { jm.Msg = "删除失败"; } } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ActionResult AddGoodsCategory(GoodsCategoryModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IGoodsCategoryBLL goodsCategoryTypeBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); T_GoodsCategory goodsCategory = new T_GoodsCategory() { Name = model.Name, ShopId = GetCurrentShopId().Value }; // 保存 goodsCategoryTypeBll.Save(goodsCategory); //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { // 保存异常日志 jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public JsonResult EditGoodsCategory(GoodsCategoryModel model) { JsonModel jm = new JsonModel(); //如果表单模型验证成功 if (ModelState.IsValid) { IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); T_GoodsCategory goodsCategory = goodsCategoryBll.GetEntity(m => m.Id == model.Id); if (goodsCategory != null) { goodsCategory.Name = model.Name; //保存到数据库 if (goodsCategoryBll.Update(goodsCategory)) { //日志记录 jm.Content = PropertyUtils.ModelToJsonString(model); } else { jm.Msg = "编辑失败"; } } else { jm.Msg = "该类别不存在"; } } else { jm.Msg = ConstantParam.JSON_RESULT_MODEL_CHECK_ERROR; } return(Json(jm, JsonRequestBehavior.AllowGet)); }
public ApiResultModel AddGoodsCategory(GoodsCategoryInfoModel model) { ApiResultModel resultModel = new ApiResultModel(); try { //获取当前商家用户 IShopUserBLL userBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL"); T_ShopUser user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT); //如果商家用户存在 if (user != null) { //如果验证Token不通过或已过期 if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token) { resultModel.Msg = APIMessage.TOKEN_INVALID; return(resultModel); } //更新最近登录时间和Token失效时间 user.LatelyLoginTime = DateTime.Now; user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid"))); userBll.Update(user); IGoodsCategoryBLL goodsBLL = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); if (goodsBLL.Exist(m => m.Name == model.Name && m.ShopId == model.ShopId)) { resultModel.Msg = "该商品类别已经存在"; } else { //商品分类实例化 T_GoodsCategory goods = new T_GoodsCategory() { Name = model.Name, ShopId = model.ShopId }; //保存商品分类 goodsBLL.Save(goods); } } else { resultModel.Msg = APIMessage.NO_USER; } } catch { resultModel.Msg = APIMessage.REQUEST_EXCEPTION; } return(resultModel); }
public ActionResult EditGoodsCategory(int id) { IGoodsCategoryBLL goodsCategoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL"); var shopId = GetCurrentShopId().Value; //获取要编辑的物业账户 T_GoodsCategory goodsCategory = goodsCategoryBll.GetEntity(m => m.Id == id && m.ShopId == shopId); if (goodsCategory != null) { //初始化返回页面的模型 GoodsCategoryModel model = new GoodsCategoryModel() { Id = goodsCategory.Id, Name = goodsCategory.Name }; return(View(model)); } else { return(RedirectToAction("GoodsCategoryList")); } }