Beispiel #1
0
        public ActionResult Index(Constants.Novel.ClassSpeType cst = Constants.Novel.ClassSpeType.female)
        {
            int timeOut = 30;

            if (SiteSection.Class.IsShowMale && !SiteSection.Class.IsShowFemale)
            {
                cst = Constants.Novel.ClassSpeType.male;
            }

            dynamic recClass = GetRecClass(cst);

            //首页-热门推荐
            var hotRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_HotRecommend", cst), () =>
            {
                return(GetRecList(recClass.HotRecommend, 7));
            }, timeOut);

            //首页-潜力新作
            var newRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_PotentialNew", cst), () =>
            {
                return(GetRecList(recClass.PotentialNew, 6));
            }, timeOut);

            //首页-主编力推
            var authorRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_EditorRecommend", cst), () =>
            {
                return(GetRecList(recClass.EditorRecommend, 3));
            }, timeOut);

            //首页-热销专区
            var sellRec = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_HotSale", cst), () =>
            {
                return(GetRecList(recClass.HotSale, 6));
            }, timeOut);

            //首页-听书专区
            var listenRec = DataContext.TryCache <IEnumerable <RecommendView> >("BookIndex_ListenRec", () =>
            {
                return(GetRecList(RecSection.BookIndex.ListenRec, 3));
            }, timeOut);

            //首页-顶端广告位
            var headAD = DataContext.TryCache <IEnumerable <AD> >(string.Format("{0}_BookIndex_HeaderAD", cst), () =>
            {
                return(GetADList(recClass.HeaderAD, 4));
            }, timeOut);

            //首页-中间广告位
            var middleAD = DataContext.TryCache <IEnumerable <AD> >(string.Format("{0}_BookIndex_MiddleAD", cst), () =>
            {
                return(GetADList(recClass.MiddleAD, 1));
            }, timeOut);

            //首页-限时免费
            var freeRec = GetPackageList((int)recClass.Free, Constants.PackageType.LimitFree, 3);

            //获取本地最近阅读
            var recentRead = RecentReadContext.First(new string[] { Constants.SecurityKey.NovelRecentRead_CookieName.ToString(), Constants.SecurityKey.CartoonRecentRead_CookieName.ToString() }, _logService, currentUser.UserName, currentUser.UserId);

            HomeView home = new HomeView()
            {
                HotRecList    = new SimpleResponse <IEnumerable <RecommendView> >(!hotRec.IsNullOrEmpty(), hotRec),
                FreeRecList   = new SimpleResponse <IEnumerable <PackageView> >(!freeRec.IsNullOrEmpty(), freeRec),
                NewRecList    = new SimpleResponse <IEnumerable <RecommendView> >(!newRec.IsNullOrEmpty(), newRec),
                AuthorRecList = new SimpleResponse <IEnumerable <RecommendView> >(!authorRec.IsNullOrEmpty(), authorRec),
                SellRecList   = new SimpleResponse <IEnumerable <RecommendView> >(!sellRec.IsNullOrEmpty(), sellRec),
                ListenRecList = new SimpleResponse <IEnumerable <RecommendView> >(!listenRec.IsNullOrEmpty(), listenRec),
                HeadADList    = new SimpleResponse <IEnumerable <AD> >(!headAD.IsNullOrEmpty(), headAD),
                MiddleADList  = new SimpleResponse <IEnumerable <AD> >(!middleAD.IsNullOrEmpty(), middleAD),
                RecentRead    = new SimpleResponse <NovelRecentReadView>(!recentRead.IsObjectNullOrEmpty(), recentRead),
                ClassSpeType  = cst.ToString()
            };

            return(View(home));
        }