コード例 #1
0
        /// <summary>
        /// 逆天笔记页面 ~ 带分页功能
        /// </summary>
        /// <param name="pi">index</param>
        /// <param name="ps">pageSize</param>
        /// <returns></returns>
        public ActionResult NotePadArticle(int pi = 1, int ps = 9)
        {
            CheckOutPages(ref pi, ref ps);

            int total;

            ViewBag.ArticleList = ArticleService.PageLoad(a => a.Status != ArticleStatusEnum.Delete && a.GroupType == GroupEnum.Note, a => new { a.UpdateTime, a.Sort }, true, pi, ps, out total).AsEnumerable().Select(a => new ArticleTemp {
                Id = a.Id, Name = a.Author, Count = a.HitCount, CreateTime = a.CreateTime.ToString("yyyy-MM-dd"), DisplayPic = a.DisplayPic, Title = a.Title, Author = a.Author, TContent = HtmlSafeHelper.GetChinese(HttpUtility.HtmlDecode(a.TContent)), ArticleTypeList = GetBottomArticleType(a.TypeIds)
            }).ToList();
            ViewBag.PageIndex = pi;
            ViewBag.PageSize  = ps;
            ViewBag.Total     = total;
            ViewBag.PageUrl   = Url.Action("Index", "Share");
            return(View());
        }
コード例 #2
0
        /// <summary>
        /// 显示Tag对应的文章
        /// </summary>
        /// <param name="id">ID为tag的id,0为全部显示</param>
        /// <param name="pi">index</param>
        /// <param name="ps">pageSize</param>
        /// <returns></returns>
        public ActionResult Tag(string id = "", int pi = 1, int ps = 9)
        {
            #region 检验id
            if (string.IsNullOrEmpty(id))
            {
                return(RedirectToAction("Index", "Index"));
            }

            int tagTypeId;
            int.TryParse(id, out tagTypeId);
            if (tagTypeId <= 0)
            {
                return(RedirectToAction("Index", "Index"));
            }
            #endregion

            CheckOutPages(ref pi, ref ps);

            string tagIds = string.Format(",{0},", id);//折中的方法

            int total;
            ViewBag.ArticleList = ArticleService.PageLoad(a => a.Status != ArticleStatusEnum.Delete && ("," + a.TagIds + ",").Contains(tagIds), a => new { a.UpdateTime }, true, pi, ps, out total).AsEnumerable().Select(a => new ArticleTemp {
                Id = a.Id, Name = a.Author, Count = a.HitCount, CreateTime = a.CreateTime.ToString("yyyy-MM-dd"), DisplayPic = a.DisplayPic, Title = a.Title, Author = a.Author, TContent = HtmlSafeHelper.GetChinese(HttpUtility.HtmlDecode(a.TContent)), ArticleTypeList = GetBottomArticleType(a.TypeIds)
            }).ToList();
            ViewBag.PageIndex = pi;
            ViewBag.PageSize  = ps;
            ViewBag.Total     = total;
            ViewBag.PageUrl   = Url.Action("Tag", "Article");
            return(View());
        }
コード例 #3
0
        /// <summary>
        /// 首页逆天推荐 ~ 带分页功能
        /// </summary>
        /// <param name="pi">index</param>
        /// <param name="ps">pageSize</param>
        /// <returns></returns>
        public ActionResult LTLikeArticle(int pi = 1, int ps = 9)
        {
            CheckOutPages(ref pi, ref ps);
            //加入a.Recommend == RecommendEnum.Top 置顶功能,a.Recommend 排序优先,top的是4最大
            int total;

            ViewBag.ArticleList = ArticleService.PageLoad(a => a.Status != ArticleStatusEnum.Delete && (a.Recommend == RecommendEnum.Dnt || a.Recommend == RecommendEnum.Top), a => new { a.Recommend, a.CreateTime, a.Sort }, true, pi, ps, out total).AsEnumerable().Select(a => new ArticleTemp {
                Id = a.Id, Name = a.Author, Count = a.HitCount, CreateTime = a.CreateTime.ToString("yyyy-MM-dd"), DisplayPic = a.DisplayPic, Title = a.Title, Author = a.Author, TContent = HtmlSafeHelper.GetChinese(HttpUtility.HtmlDecode(a.TContent)), ArticleTypeList = GetBottomArticleType(a.TypeIds)
            }).ToList();
            ViewBag.PageIndex = pi;
            ViewBag.PageSize  = ps;
            ViewBag.Total     = total;
            ViewBag.PageUrl   = Url.Action("Index", "Index");
            return(View());
        }