示例#1
0
 /// <summary>
 /// 添加内容信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public long AddAndUpdateContentInfo(Syscontent model)
 {
     if (model == null)
     {
         return(0);
     }
     return(_dataAccess.AddAndUpdateContentInfo(model));
 }
示例#2
0
        public ActionResult AddContentInfo(Syscontent model)
        {
            var resultMode = new ResponseBaseModel <Syscontent>
            {
                ResultCode = ResponceCodeEnum.Fail
            };

            if (string.IsNullOrEmpty(model.Content))
            {
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            if (string.IsNullOrEmpty(model.Introduction))
            {
                var introduction = FilterHtmlHelper.NoHtml(model.Content);
                model.Introduction = introduction != null && introduction.Length > 200 ? introduction.Substring(0, 200) : introduction;
            }
            var  server = new ContentService();
            long id;

            if (model.Id > 0)
            {
                var oldModel = server.GetContentModel(model.Id);
                if (oldModel == null)
                {
                    resultMode.Message = "不存在该内容记录";
                    return(Json(resultMode, JsonRequestBehavior.AllowGet));
                }

                oldModel.Content            = model.Content;
                oldModel.ContentSource      = model.ContentSource;
                oldModel.ContentType        = model.ContentType;
                oldModel.ContentFlag        = model.ContentFlag;
                oldModel.Introduction       = model.Introduction;
                oldModel.Title              = model.Title;
                oldModel.ContentDisImage    = model.ContentDisImage;
                oldModel.AttachmentFile     = model.AttachmentFile;
                oldModel.AttachmentFileName = model.AttachmentFileName;
                oldModel.AttachmentFileSize = model.AttachmentFileSize;
                id = server.AddAndUpdateContentInfo(oldModel);
            }
            else
            {
                model.CreateTime   = DateTime.Now;
                model.CreateUserId = CurrentModel.UserId;
                model.IsDel        = FlagEnum.HadZore.GetHashCode();
                id = server.AddAndUpdateContentInfo(model);
            }
            if (id > 0)
            {
                resultMode.ResultCode = ResponceCodeEnum.Success;
                resultMode.Message    = "处理成功";
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }
            resultMode.Message = "处理失败";
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }
示例#3
0
 /// <summary>
 /// 添加信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public long AddAndUpdateContentInfo(Syscontent model)
 {
     if (model == null)
     {
         return(0);
     }
     using (var conn = SqlConnectionHelper.GetOpenConnection())
     {
         if (model.Id > 0)
         {
             return(conn.Update(model));
         }
         return(conn.Insert <long, Syscontent>(model));
     }
 }
示例#4
0
        public ActionResult GetContentInfo(long id)
        {
            var resultMode = new ResponseBaseModel <Syscontent>
            {
                ResultCode = ResponceCodeEnum.Fail
            };
            var model = new Syscontent();

            if (id < 1)
            {
                resultMode.Message    = "响应成功";
                resultMode.ResultCode = ResponceCodeEnum.Success;
                resultMode.Data       = model;
                return(Json(resultMode, JsonRequestBehavior.AllowGet));
            }

            model = new ContentService().GetContentModel(id);
            resultMode.Message    = "响应成功";
            resultMode.ResultCode = ResponceCodeEnum.Success;
            resultMode.Data       = model;
            return(Json(resultMode, JsonRequestBehavior.AllowGet));
        }