コード例 #1
0
        public ActionResult Add(string Name)
        {
            AjaxResponse<ArticleTag> obj = new AjaxResponse<ArticleTag>();

            if (string.IsNullOrEmpty(Name))
            {
                obj.ErrorMessage = "分类名称不能为空";
                return Json(obj);
            }

            if (Name.Length > 15)
            {
                obj.ErrorMessage = "分类名称不能超过15个字";
                return Json(obj);
            }

            //保证Name唯一,先查询一下是不是有这个Name
            var temp = ArticleTagService.PageLoad(a => a.Name == Name).FirstOrDefault();
            if (temp != null)
            {
                obj.ErrorMessage = "该分类已经存在!";
                return Json(obj);
            }

            ArticleTag ArticleTag = new ArticleTag { Name = Name, Status = StatusEnum.Normal };

            obj.IsSuccess = ArticleTagService.AddModel(ArticleTag);
            return Json(obj);
        }
コード例 #2
0
        public JsonResult Update(string Name, int Status, int Id = 0)
        {
            AjaxResponse<ArticleTag> obj = new AjaxResponse<ArticleTag>();

            if (string.IsNullOrEmpty(Name))
            {
                obj.ErrorMessage = "分类名称不能为空";
                return Json(obj);
            }

            if (Name.Length > 15)
            {
                obj.ErrorMessage = "分类名称不能超过15个字";
                return Json(obj);
            }

            ArticleTag ArticleTag = new ArticleTag { Id = Id, Name = Name, Status = Status != 99 ? StatusEnum.Normal : StatusEnum.Delete };

            obj.IsSuccess = ArticleTagService.UpdateModel(ArticleTag);

            return Json(obj);
        }