Exemplo n.º 1
0
        public JsonResult Save(string blockId)
        {
            try
            {
                if (!IsSavePermission(blockId))
                {
                    return(Error("您没有操作权限,请联系系统管理员!"));
                }

                string fTitle   = GetFormValue("fTitle");
                string fTags    = GetFormValue("fTags");
                string fContent = GetFormValue("fContent");

                if (string.IsNullOrWhiteSpace(fTitle))
                {
                    return(Error("区块说明不能为空!"));
                }
                if (string.IsNullOrWhiteSpace(fTags))
                {
                    return(Error("标签不能为空!"));
                }
                if (string.IsNullOrWhiteSpace(fContent))
                {
                    return(Error("内容不能为空!"));
                }

                var entity = new Info_Block()
                {
                    SystemID   = SystemID,
                    CompanyID  = CompanyID,
                    BlockID    = blockId,
                    Title      = fTitle,
                    Tags       = fTags,
                    Content    = fContent,
                    State      = true,
                    CreateDate = DateTime.Now
                };
                bool result = false;
                if (string.IsNullOrEmpty(blockId))
                {
                    result = BlockService.SaveBlock(entity);
                }
                else
                {
                    result = BlockService.UpdateBlock(entity);
                }
                if (result)
                {
                    return(Success("ok"));
                }
                else
                {
                    return(Error("fail"));
                }
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }