/// <summary> /// 后台的文章静态处理 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult StaticHtml(int id) { ArticleBLL articleBLL = new ArticleBLL(); ArticleEntity articleEntity = articleBLL.GetArticleEntityById(id); string staticURL = "/"; //生成文章静态URL ArticleCategoryBLL articleCategoryBLL = new ArticleCategoryBLL(); ArticleCategoryEntity categoryEntity = articleCategoryBLL.GetArticleCategoryEntityById(articleEntity.CategoryId); articleEntity.HrefTpl = categoryEntity.HrefTpl; if (!string.IsNullOrEmpty(categoryEntity.HrefTpl)) { //查文章对应的期刊 if (articleEntity.ArticlePropertyId.HasValue) { JournalArticleRelationBLL journalArticleRelationBLL = new JournalArticleRelationBLL(); JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(articleEntity.ArticlePropertyId); ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL(); ArticleJournalEntity articleJournalEntity = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId); articleEntity.JournalId = articleJournalEntity.JournalId; //期刊Id articleEntity.JournalName = articleJournalEntity.JournalName; //期刊名 articleEntity.PropertyName = articleJournalEntity.PropertyName; //期刊总序号 staticURL += articleEntity.Href + "?JournalId=" + articleEntity.JournalId + "&static=1"; return(Redirect(staticURL)); } staticURL += articleEntity.Href + "&static=1"; return(Redirect(staticURL)); } return(new EmptyResult()); }
/// <summary> /// 文章预览 /// </summary> /// <param name="id">文章Id</param> /// <returns></returns> public ActionResult Perview(int id) { ArticleBLL articleBLL = new ArticleBLL(); ArticleEntity articleEntity = articleBLL.GetArticleEntityById(id); string staticURL = "/"; //生成文章静态URL ArticleCategoryBLL articleCategoryBLL = new ArticleCategoryBLL(); ArticleCategoryEntity categoryEntity = articleCategoryBLL.GetArticleCategoryEntityById(articleEntity.CategoryId); //TODO 判断文章没有任何分类的情况 articleEntity.HrefTpl = categoryEntity != null ? categoryEntity.HrefTpl : "nocategory{0}.html";//文章没有类别时,详细页URL if (!string.IsNullOrEmpty(articleEntity.HrefTpl)) { //查文章对应的期刊 if (articleEntity.ArticlePropertyId.HasValue) { JournalArticleRelationBLL journalArticleRelationBLL = new JournalArticleRelationBLL(); JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(articleEntity.ArticlePropertyId); ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL(); ArticleJournalEntity articleJournalEntity = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId); articleEntity.JournalId = articleJournalEntity.JournalId; //期刊Id articleEntity.JournalName = articleJournalEntity.JournalName; //期刊名 articleEntity.PropertyName = articleJournalEntity.PropertyName; //期刊总序号 staticURL += articleEntity.Href + "?JournalId=" + articleEntity.JournalId; return(Redirect(staticURL)); } staticURL += articleEntity.Href; return(Redirect(staticURL)); } return(new EmptyResult()); }
public string Edit(ArticleEntity articleUpdate) { var errors = ModelState.Values.SelectMany(v => v.Errors).ToList();//查找具体出错的模型字段 //ModelState.Remove("Id"); if (ModelState.IsValid) { ArticleBLL articleBLL = new ArticleBLL(); ArticleEntity article = articleBLL.GetArticleEntityById(articleUpdate.Id); article.ArticleTitle = articleUpdate.ArticleTitle.UrlDecode(); //文章标题 article.ArticleTitleAlias = articleUpdate.ArticleTitleAlias.UrlDecode(); article.ArticleContent = articleUpdate.ArticleContent.UrlDecode(); //文章内容 article.CategoryId = articleUpdate.CategoryId; article.NoOfJournal = articleUpdate.NoOfJournal; article.NoOfCategory = articleUpdate.NoOfCategory; article.IsPublic = articleUpdate.IsPublic; //article.IsTop = articleUpdate.IsTop; if (article.ArticlePropertyId.HasValue) { JournalArticleRelationBLL journalArticleRelationBLL = new JournalArticleRelationBLL(); JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(article.ArticlePropertyId); ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL(); ArticleJournalEntity articleJournalEntity = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId); article.JournalId = articleJournalEntity.JournalId; } articleBLL.UpdateArticleEntity(article); //TODO Step3 维护照片关系 this.ArticleImageSave(articleUpdate); string returnUrl = article.JournalId.HasValue ? "/Admin/Article/Index?JournalId=" + article.JournalId : "/Admin/Article/Index"; return(JsonConvert.SerializeObject(new { result = true, message = "", returnUrl = returnUrl })); } return(JsonConvert.SerializeObject(new { result = false, message = "" })); }
public ActionResult Edit(int id) { ArticleBLL articleBLL = new ArticleBLL(); ArticleEntity articleEntity = articleBLL.GetArticleEntityById(id); //查文章对应的期刊 if (articleEntity.ArticlePropertyId.HasValue) { JournalArticleRelationBLL journalArticleRelationBLL = new JournalArticleRelationBLL(); JournalArticleRelationEntity journalArticleRelationEntity = journalArticleRelationBLL.GetJournalArticleRelationEntityById(articleEntity.ArticlePropertyId); ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL(); ArticleJournalEntity articleJournalEntity = articleJournalBLL.GetArticleJournalEntityById(journalArticleRelationEntity.JournalId); articleEntity.JournalName = articleJournalEntity.JournalName; articleEntity.PropertyName = articleJournalEntity.PropertyName; articleEntity.JournalId = articleJournalEntity.JournalId;//文章所属期刊Id } /* * ArticleJournalBLL articleJournalBLL = new ArticleJournalBLL();//1.获取期刊 * List<SqlDbParameter> parms = new List<SqlDbParameter>(); * SqlDbParameter para = new SqlDbParameter(); * List<ArticleJournalEntity> journalList = articleJournalBLL.GetAllArticleJournal(parms); * ViewBag.ArticleProperty = new SelectList(journalList, "JournalId", "JournalName", articleEntity.JournalId); */ //文章分类 TODO ArticleCategoryBLL articleCategoryBLL = new ArticleCategoryBLL(); List <SqlDbParameter> parms = new List <SqlDbParameter>(); List <ArticleCategoryEntity> articleCategory = articleCategoryBLL.GetAllArticleCategory(parms, "Id"); articleCategory.Insert(0, new ArticleCategoryEntity() { CategoryName = "请选择" }); var selectList = new SelectList(articleCategory, "Id", "CategoryName", articleEntity.CategoryId); ViewBag.ArticleCategory = selectList; return(View(articleEntity)); }