コード例 #1
0
ファイル: AppController.cs プロジェクト: riyuexing/Mock.luo
        public override ActionResult Index()
        {
            //标签
            List <TreeSelectModel> tagItemsList = _itemsDetailRepository.GetCombobox("Tag");

            tagItemsList.RemoveAt(0);
            ViewData["Tag"] = tagItemsList;

            //最新文章
            List <ArtDetailDto> latestArticles = _articleRepository.GetRecentArticle(5);

            ViewData["LatestArticles"] = latestArticles;

            //最热文章
            List <Article> hotArticles = _articleRepository.GetHotArticle(8);

            ViewData["HotArticles"] = hotArticles;

            //吐槽
            List <ReplyDto> spitslotList = _reviewRepository.GetRecentReview(8);

            ViewData["SpitslotList"] = spitslotList;

            //统计
            SiteStatistics site = _articleRepository.GetSiteData();

            ViewData["Site"] = site;

            //轻松时刻 | 缓存
            ViewData["JustFun"] = _iredisHelper.UnitOfWork(string.Format(ConstHelper.App, "JustFun"), () =>
            {
                List <ArtDetailDto> justFunList = _articleRepository.GetArticleList(_articleRepository.Queryable(u => u.DeleteMark == false && u.ItemsDetail.ItemCode == CategoryCode.Justfun.ToString())).OrderByDescending(u => u.Id).Take(5).ToList();
                if (justFunList.Count > 0)
                {
                    justFunList[0].Content = Server.UrlDecode(justFunList[0].Content);
                }
                return(justFunList);
            });

            //人生感悟 | 缓存
            ViewData["FellLife"] = _iredisHelper.UnitOfWork(string.Format(ConstHelper.App, "FellLife"), () =>
            {
                List <ArtDetailDto> feLifeList = _articleRepository.GetArticleList(_articleRepository.Queryable(u => u.DeleteMark == false && u.ItemsDetail.ItemCode == CategoryCode.Feelinglife.ToString())).OrderByDescending(u => u.Id).Take(5).ToList();
                if (feLifeList.Count > 0)
                {
                    feLifeList[0].Content = Server.UrlDecode(feLifeList[0].Content);
                }
                return(feLifeList);
            });

            return(base.Index());
        }
コード例 #2
0
 /// <summary>
 /// 根据主表的编码,获取分表ItemsDetail的关联数据,做为下拉列表数据
 /// </summary>
 /// <param name="encode"></param>
 /// <returns></returns>
 public ActionResult GetCombobox(string encode)
 {
     return(CamelCaseJson(_itemsDetailRepository.GetCombobox(encode)));
 }