//按ID获取标签 public ActionResult GetLabelById(int id) { ProductLabelService labelDal = new ProductLabelService(); SWfsProductLabel obj = labelDal.GetLabelById(id); return(Json(obj, JsonRequestBehavior.AllowGet)); }
//修改标签 public ActionResult EditeLabel(int labelId, string labelName, string parentNo, short labelType, string labelNiceName) { int result = 0; labelName = Server.UrlDecode(labelName); ProductLabelService labelDal = new ProductLabelService(); if (string.IsNullOrEmpty(parentNo)) { return(Json(new { code = 1, msg = "父类不存在" }, JsonRequestBehavior.AllowGet)); } if (parentNo.ToLower() == "root") { if (string.IsNullOrEmpty(labelNiceName)) { return(Json(new { code = 1, msg = "标签别名不能为空" }, JsonRequestBehavior.AllowGet)); } } //验证是否重复 if (labelDal.IsExistSameLabel(parentNo, labelName, labelId) > 0) { return(Json(new { code = 1, msg = "该标签已存在" }, JsonRequestBehavior.AllowGet)); } int n = labelDal.EditeLabel(new SWfsProductLabel { LabelId = labelId, LabelName = labelName, ParentNo = parentNo, LabelType = labelType, LabelNickName = labelNiceName }); return(Json(new { code = n > 0 ? 0 : 1, msg = n > 0 ? "修改成功" : "修改失败" }, JsonRequestBehavior.AllowGet)); }
public ActionResult ProductLabelManager() { ProductLabelService labelDal = new ProductLabelService(); IEnumerable <SWfsProductLabel> LabelList = labelDal.GetLabelList(); if (!string.IsNullOrEmpty(Request.QueryString["labelName"])) { string labelName = Request.QueryString["labelName"].ToString(); //筛选出包含搜索标签名的标签数据 var result1 = from p in LabelList where (p.LabelName.IndexOf(labelName, 0, StringComparison.OrdinalIgnoreCase) > -1) select p; //筛选出要返回客户端的标签数据 var result2 = from p in LabelList where result1.Count(i => i.LabelNo == p.LabelNo | p.ParentNo == i.LabelNo | p.LabelNo == i.ParentNo | (p.ParentNo == i.ParentNo && p.ParentNo != "Root")) > 0 select p; return(View(result2)); } return(View(LabelList)); }
public ProductLabelController() { productLabelService = new ProductLabelService(); }