コード例 #1
0
ファイル: AdminController.cs プロジェクト: 91mvc/YQCMS
        public ActionResult AdminAdd(ArticleModel model)
        {
            //添加[ValidateInput(false)]特性,否则提交内容有html代码会报错
            if (ModelState.IsValid)
            {
                cms_varticle obj = new cms_varticle();
                CategoryModel category = cmsService.GetCategoryByID(model.CateId);
                obj.articleid = 0;
                obj.typeid = Utils.StrToInt(category.Type);
                obj.cateid = model.CateId;
                obj.catename = category.CateName;
                obj.catepath = category.Path; ;
                obj.title = Utils.FileterStr(model.Title);
                obj.summary = Utils.FileterStr(Server.UrlDecode(model.Summary));
                obj.content = Utils.FileterStr(Server.UrlDecode(Utils.DownloadImages(model.Content, "/Content"+configinfo.WebPath+"Upload/", configinfo.Weburl)));
                obj.ip = Utils.GetIP();
                obj.tags = (string.IsNullOrWhiteSpace(model.Tags) ? "" : model.Tags).Trim();
                obj.layer = 0;
                obj.orderid = 1;
                obj.parentid = 0;
                obj.replypermit = model.ReplyPermit;
                obj.seodescription = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoDescription) ? "" : model.SeoDescription)).Trim();
                obj.seokeywords = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.Seokeywords) ? "" : model.Seokeywords)).Trim();
                obj.seometas = string.IsNullOrWhiteSpace(model.SeoMetas) ? "" : model.SeoMetas;
                obj.seotitle = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.SeoTitle) ? "" : model.SeoTitle)).Trim();
                obj.rename = Utils.RemoveHtml((string.IsNullOrWhiteSpace(model.ReName) ? "" : model.ReName)).Trim();
                obj.status = model.Status;
                obj.userid = 1;
                obj.username = User.Identity.Name;
                obj.iscommend = model.IsCommend;
                obj.istop = model.IsTop;

                int re=cmsService.AddArticle(obj);

                return Redirect(configinfo.WebPath+"Admin/AdminArticle/?tid="+obj.typeid);

            }
            return View(model);
        }
コード例 #2
0
ファイル: AdminController.cs プロジェクト: 91mvc/YQCMS
        /// <summary>
        /// 文章修改
        /// </summary>
        public ActionResult AdminEdit(int id)
        {
            ViewBag.CI = configinfo;
            //根据ID获取文章信息
            cms_varticle obj = new cms_varticle();
            obj = cmsService.GetArticleByID(id);

            //把修改操作需要的字段赋给ArticleModel对象
            ArticleModel model = new ArticleModel();
            model.ID = obj.id;
            model.CateId = obj.cateid;
            model.Title = Utils.FileterStr(obj.title);
            model.Summary = string.IsNullOrWhiteSpace(obj.summary) ? "" : obj.summary;
            model.Content = string.IsNullOrWhiteSpace(obj.content) ? "" : obj.content;
            model.Tags = string.IsNullOrWhiteSpace(obj.tags) ? "" : obj.tags;
            model.SeoDescription = string.IsNullOrWhiteSpace(obj.seodescription) ? "" : obj.seodescription;
            model.Seokeywords = string.IsNullOrWhiteSpace(obj.seokeywords) ? "" : obj.seokeywords;
            model.SeoMetas = string.IsNullOrWhiteSpace(obj.seometas) ? "" : obj.seometas;
            model.SeoTitle = string.IsNullOrWhiteSpace(obj.seotitle) ? "" : obj.seotitle;
            model.ReName = string.IsNullOrWhiteSpace(obj.rename) ? "" : obj.rename;
            model.Status = obj.status;
            model.ReplyPermit = obj.replypermit;
            model.IsCommend = obj.iscommend;
            model.IsTop = obj.istop;

            ViewData["CateId"] = new SelectList(cmsService.getFCategoryList(obj.typeid.ToString(),""," -- "), "CateId", "CateName", model.CateId);
            return View(model);
        }