Пример #1
0
 public ActionResult SubmitForm(TbArticle model, string type)
 {
     try
     {
         if (type == "add")
         {
             model.InsertUserCode = base.UserCode;
             var data = _article.Insert(model);
             return(Content(data.ToJson()));
         }
         else
         {
             var data = _article.Update(model);
             return(Content(data.ToJson()));
         }
     }
     catch (Exception)
     {
         return(Error(""));
     }
 }
Пример #2
0
        /// <summary>
        /// 新增数据(文章)
        /// </summary>
        public AjaxResult Insert(TbArticle model, bool isApi = false)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            model.CommentCount = 0;
            model.BrowseCount  = 0;
            model.CollectCount = 0;
            model.Type         = 1;
            try
            {
                //添加信息
                Repository <TbArticle> .Insert(model, isApi);

                return(AjaxResult.Success());
            }
            catch (Exception)
            {
                return(AjaxResult.Error());
            }
        }
Пример #3
0
        /// <summary>
        /// 修改数据
        /// </summary>
        public AjaxResult Update(TbArticle model, bool isApi = false)
        {
            if (model == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            var anyRet = AnyInfo(model.ID);

            if (anyRet.state != ResultType.success.ToString())
            {
                return(anyRet);
            }
            try
            {
                Repository <TbArticle> .Update(model, p => p.ID == model.ID, isApi);

                return(AjaxResult.Success());
            }
            catch (Exception ex)
            {
                return(AjaxResult.Error(ex.ToString()));
            }
        }