Exemple #1
0
        public IActionResult Index(Models.ContentsEditRequestModel requestModel)
        {
            if (string.IsNullOrEmpty(requestModel.Title) || requestModel.Title == "")
            {
                return(APIReturnMethod.ReturnFailed("标题不能为空"));
            }
            if (string.IsNullOrEmpty(requestModel.Contents) || requestModel.Contents == "")
            {
                return(APIReturnMethod.ReturnFailed("内容不能为空"));
            }
            var repository = _unitOfWork.GetRepository <Entity.m_CmsContents>();

            //
            Entity.m_CmsContents entity = repository.Query().Where(q => q.ContentsId == requestModel.ContentsId).FirstOrDefault();
            entity.Contents   = requestModel.Contents;//Framework.Core.HtmlFilter.SanitizeHtml(model.Contents);
            entity.LastTime   = DateTime.Now;
            entity.Title      = requestModel.Title;
            entity.ContentsId = requestModel.ContentsId;
            entity.ChannelId  = requestModel.ChannelId;

            repository.Update(entity);
            int resultCount = _unitOfWork.SaveChanges();

            return(resultCount > 0 ? APIReturnMethod.ReturnSuccess() : APIReturnMethod.ReturnFailed());
        }
        public IActionResult Index(Models.ContentsEditRequestModel requestModel)
        {
            //requestModel.AccountId = HttpContext.Session.GetInt32("AccountId").GetValueOrDefault(0);

            string requestData = JsonConvert.SerializeObject(requestModel);
            var    apiResult   = HttpCore.HttpPut($"/api/CMS/Contents", requestData);

            return(Json(apiResult));
        }