Ejemplo n.º 1
0
        /// <summary>
        /// 添加博客标签链接
        /// </summary>
        /// <param name="bl"></param>
        /// <returns></returns>
        public IActionResult AddorUpdateBlogLable(BlogLableDto bl)
        {
            var resModel     = new ResponseModel();
            var handleResult = _blogLableBLL.AddorEditBlogLable(bl, _userAccount.GetUserInfo().UserId);

            resModel.RetCode = handleResult.Result ? StatesCode.success : StatesCode.failure;
            resModel.RetMsg  = handleResult.Msg;
            resModel.Data    = handleResult.Data;
            return(Ok(resModel));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加/编辑博客标签
        /// </summary>
        /// <param name="bl"></param>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public HandleResult <bool> AddorEditBlogLable(BlogLableDto bl, string UserId)
        {
            var handleResult = new HandleResult <bool>();
            var blogLable    = Mapper.Map <BlogLable>(bl);

            //添加
            if (blogLable.LableId == 0)
            {
                int intcount = _blogLableDAL.GetCount(t => t.LableName.Equals(blogLable.LableName) && t.DeleteSign.Equals((int)DeleteSign.Sing_Deleted));
                if (intcount > 0)
                {
                    handleResult.Msg    = "博客标签名称已注册";
                    handleResult.Result = false;
                }
                else
                {
                    blogLable.CreateTime   = DateTime.Now;
                    blogLable.EditTime     = DateTime.Now;
                    blogLable.DeleteSign   = (Int32)DeleteSign.Sing_Deleted;
                    blogLable.CreateUserId = UserId;
                    if (Add(blogLable))
                    {
                        handleResult.Msg = "添加成功";
                    }
                    else
                    {
                        handleResult.Msg    = "添加失败";
                        handleResult.Result = false;
                    }
                }
            }
            else//修改
            {
                var edit = GetModels(t => t.LableId == blogLable.LableId).SingleOrDefault();
                edit.LableId   = blogLable.LableId;
                edit.LableName = blogLable.LableName;
                edit.Note      = blogLable.Note;
                edit.EditTime  = DateTime.Now;
                if (Update(edit))
                {
                    handleResult.Msg = "修改成功";
                }
                else
                {
                    handleResult.Msg = "修改失败";
                }
            }
            return(handleResult);
        }