Пример #1
0
        public JsonResult CheckLabelIsExist(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new HimallException("标签名不能为空!");
            }
            var labels = MemberLabelApplication.GetLabelList(new LabelQuery
            {
                LabelName = name
            });

            if (labels.Models.Count > 0)
            {
                throw new HimallException("标签已经存在,不能重复!");
            }
            return(Json(new { Success = true }));
        }
Пример #2
0
        public JsonResult Label(LabelModel model)
        {
            LabelInfo labelmodel = new LabelInfo()
            {
                Id        = model.Id,
                LabelName = model.LabelName
            };

            if (MemberLabelApplication.CheckNameIsExist(model.LabelName))
            {
                throw new HimallException("标签已经存在,不能重复!");
            }
            if (labelmodel.Id > 0)
            {
                _iMemberLabelService.UpdateLabel(labelmodel);
            }
            else
            {
                _iMemberLabelService.AddLabel(labelmodel);
            }
            return(Json(new { Success = true }));
        }