/// <summary> /// 文章修改页面 /// </summary> /// <param name="GroupType">文章类别(资讯1 笔记2 网络资源3)</param> /// <returns></returns> public ActionResult Update(int GroupType = 1, int ArticleId = 0) { Article article = ArticleService.FindModel(ArticleId); //不存在就跳转到添加页面 if (article == null) { return(RedirectToAction("Add", new { GroupType = GroupType })); } ViewBag.GroupType = GroupType; ViewBag.ArticleTags = ArticleTagService.PageLoad(t => t.Status != StatusEnum.Delete); #region 文章分类(三级) ViewBag.ArticleTopType = ArticleTypeService.PageLoad(at => at.Status != StatusEnum.Delete && (at.Pid == 0 || at.Pid == null)); int[] ids = article.TypeIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(i => int.Parse(i)).ToArray(); if (ids.Length == 0) { return(View(article)); } int oneId; int twoId; int threeId; switch (ids.Length) { case 1: oneId = ids[0]; ViewBag.TypeOneId = oneId; break; case 2: oneId = ids[0]; twoId = ids[1]; ViewBag.TypeOneId = oneId; ViewBag.TypeTwoId = twoId; ViewBag.TypeTwo = ArticleTypeService.PageLoad(at => at.Pid == oneId && at.Status != StatusEnum.Delete); break; case 3: oneId = ids[0]; twoId = ids[1]; threeId = ids[2]; ViewBag.TypeOneId = oneId; ViewBag.TypeTwoId = twoId; ViewBag.TypeThreeId = threeId; ViewBag.TypeTwo = ArticleTypeService.PageLoad(at => at.Pid == oneId && at.Status != StatusEnum.Delete); ViewBag.TypeThree = ArticleTypeService.PageLoad(at => at.Pid == twoId && at.Status != StatusEnum.Delete); break; } #endregion return(View(article)); }
/// <summary> /// 添加文章页面 /// </summary> /// <param name="GroupType">文章类别(资讯1 笔记2 网络资源3)</param> /// <returns></returns> public ActionResult Add(int GroupType = 1) { ViewBag.ArticleTopType = ArticleTypeService.PageLoad(at => at.Status != StatusEnum.Delete && (at.Pid == 0 || at.Pid == null)); ViewBag.GroupType = GroupType; ViewBag.ArticleTags = ArticleTagService.PageLoad(t => t.Status != StatusEnum.Delete); //后期可删除==>浏览量 Random r = new Random(); ViewBag.HitNum = r.Next(100, 1000); return(View()); }