public ActionResult CopyArticle(int ccid, int id) { //1、查询 module_articleContract article = new module_articleContract(); article = ArticleBll.GetArticleByIdAndccid(ccid, id); article.AddDate = DateTime.Now; article.IsPass = 1; if (ArticleBll.InsertArticle(article) > 0) { // Success ViewData["msg"] = "克隆成功!"; ViewData["url"] = Url.Action("ArticleList", new { ccid = ccid }); return View("Success"); } else { ViewData["msg"] = "克隆成功!"; ViewData["url"] = Url.Action("ArticleList", new { ccid = ccid }); return View("Error"); } }
public ActionResult ArticleEdit(module_articleContract ArticleC, FormCollection fc, int ccid, int id) { ViewData["ccid"] = ccid; string operateType = Request.QueryString["operateType"]; if (ModelState.IsValid) { if (ArticleC.Summary == null || ArticleC.Summary.Trim() == "") ArticleC.Summary = CommonHelper.GetCutString(CommonHelper.NoHTML(ArticleC.Content), 100); else ArticleC.Summary = CommonHelper.GetCutString(CommonHelper.NoHTML(ArticleC.Summary), 100); if (ArticleC.Tags == null) ArticleC.Tags = ""; else ArticleC.Tags = CommonHelper.DelSymbol(ArticleC.Tags); if (ArticleC.TColor == null) ArticleC.TColor = ""; if (ArticleC.Author == null) ArticleC.Author = ""; if (ArticleC.Img == null) { ArticleC.Img = ""; ArticleC.IsImg = 0; } else ArticleC.IsImg = 1; ArticleC.IsPass = 1; if (ArticleC.SourceFrom == null) ArticleC.SourceFrom = ""; ArticleC.Title = CommonHelper.SafetyTitle(ArticleC.Title); ArticleC.ChannelId = ccid; ArticleC.Editor = ArticleC.Author; ArticleC.FirstPage = ""; ArticleC.AliasPage = ""; switch (operateType) { case "add": #region Add ArticleC.AddDate = DateTime.Now; if (ArticleBll.InsertArticle(ArticleC) > 0) { // Success ViewData["msg"] = "添加成功!"; ViewData["url"] = Url.Action("ArticleList", new { ccid = ccid }); return View("Success"); } else { return View(ArticleC); } #endregion case "edit": if (ArticleBll.UpdateArticle(ArticleC) > 0) { // Success ViewData["msg"] = "修改成功!"; ViewData["url"] = Url.Action("ArticleList", new { ccid = ccid }); return View("Success"); } else { return View(ArticleC); } default: break; } return View(); } else { return View(ArticleC); } }
/// <summary> /// 修改文章 /// </summary> /// <param name="article"></param> /// <returns></returns> public int UpdateArticle(module_articleContract article) { return ArticleDao.UpdateArticle(article.ToPO<module_article>()); }
/// <summary> /// 添加、编辑文章 /// </summary> /// <param name="ccid">频道ID</param> /// <returns></returns> public ActionResult ArticleEdit(int id, int ccid) { ViewData["ccid"] = ccid; string operateType = Request.QueryString["operateType"]; module_articleContract Article = new module_articleContract(); //查询该频道下的栏目 List<normal_class> Classlist = ClassBll.GetClassByccidAndEid(ccid, (Session["user"] as UsersContract).EId); if (Classlist.Count == 0) { ViewData["msg"] = "该频道下还没有栏目,请先添加栏目!"; ViewData["url"] = Url.Action("AddClass", new { ccid = ccid, id = 0, operateType = "add" }); return View("Error"); } else { ViewData["ClassList"] = new SelectList(Classlist, "id", "title"); switch (operateType) { case "add": ViewBag.pTitle = "添加文章"; Article.AddDate = DateTime.Now; //添加 break; case "edit": Article = ArticleBll.GetArticleByIdAndccid(ccid, id); ViewData["content"] = Article.Content; break; default: break; } return View(Article); } }
/// <summary> /// 添加文章 /// </summary> /// <param name="article"></param> /// <returns></returns> public int InsertArticle(module_articleContract article) { return ArticleDao.InsertArticle(article.ToPO<module_article>()); }