コード例 #1
0
        public ActionResult Add(string Name, int LinkType, int Sort, string WebUrl)
        {
            AjaxResponse<FriendLink> obj = new AjaxResponse<FriendLink>();

            if (string.IsNullOrEmpty(Name))
            {
                obj.ErrorMessage = "标题不能为空";
                return Json(obj);
            }

            if (Name.Length > 15)
            {
                obj.ErrorMessage = "标题不能超过15个字";
                return Json(obj);
            }

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

            FriendLink FriendLink = new FriendLink { LinkName = Name, LinkType = (LinkTypeEnum)LinkType, Sort = Sort, WebUrl = WebUrl, Status = StatusEnum.Normal };

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

            if (string.IsNullOrEmpty(Name))
            {
                obj.ErrorMessage = "标题不能为空";
                return Json(obj);
            }

            if (Name.Length > 15)
            {
                obj.ErrorMessage = "标题不能超过15个字";
                return Json(obj);
            }

            FriendLink FriendLink = new FriendLink { Id = Id, LinkName = Name, LinkType = (LinkTypeEnum)LinkType, Sort = Sort, WebUrl = WebUrl, Status = Status != 99 ? StatusEnum.Normal : StatusEnum.Delete };

            obj.IsSuccess = FriendLinkService.UpdateModel(FriendLink);

            return Json(obj);
        }