Beispiel #1
0
        /// <summary>
        /// 免费专区
        /// </summary>
        /// <returns></returns>
        public ActionResult Free(Constants.Novel.ClassSpeType cst = Constants.Novel.ClassSpeType.female)
        {
            int timeOut = 30;

            dynamic recClass = GetRecClass(cst);

            IEnumerable <RecommendView> newFreeList = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_LimitFree_New", cst), () =>
            {
                return(GetRecList(recClass.New, 3));
            }, timeOut);

            IEnumerable <RecommendView> hotFreeList = DataContext.TryCache <IEnumerable <RecommendView> >(string.Format("{0}_BookIndex_Hot", cst), () =>
            {
                return(GetRecList(recClass.Hot, 3));
            }, timeOut);

            IEnumerable <PackageView> limitFreeList = GetPackageList((int)recClass.Limit, Constants.PackageType.LimitFree, 4);

            BookFreeView free = new BookFreeView()
            {
                NewFreeList   = new SimpleResponse <IEnumerable <RecommendView> >(!newFreeList.IsNullOrEmpty(), newFreeList),
                HotFreeList   = new SimpleResponse <IEnumerable <RecommendView> >(!hotFreeList.IsNullOrEmpty(), hotFreeList),
                LimitFreeList = new SimpleResponse <IEnumerable <PackageView> >(!limitFreeList.IsNullOrEmpty(), limitFreeList),
            };

            return(View(free));
        }
Beispiel #2
0
        private dynamic GetRecClass(Constants.Novel.ClassSpeType speType)
        {
            if (speType == Constants.Novel.ClassSpeType.male)
            {
                return new
                       {
                           HotRecommend    = RecSection.BookIndex.MaleHotRec,    //热门推荐
                           PotentialNew    = RecSection.BookIndex.MaleNewRec,    //潜力新作
                           EditorRecommend = RecSection.BookIndex.MaleEditorRec, //主编力推
                           HotSale         = RecSection.BookIndex.MaleSaleRec,   //热销专区
                           Free            = RecSection.LimitFree.MaleIndexRec,  //限时免费
                           HeaderAD        = RecSection.BookIndex.MaleTopAd,     //顶部广告位
                           MiddleAD        = RecSection.BookIndex.MaleMiddleAd   //中间广告位
                       }
            }
            ;
            else
            {
                return new
                       {
                           HotRecommend    = RecSection.BookIndex.FemaleHotRec,    //热门推荐
                           PotentialNew    = RecSection.BookIndex.FemaleNewRec,    //潜力新作
                           EditorRecommend = RecSection.BookIndex.FemaleEditorRec, //主编力推
                           HotSale         = RecSection.BookIndex.FemaleSaleRec,   //热销专区
                           Free            = RecSection.LimitFree.FemaleIndexRec,  //限时免费
                           HeaderAD        = RecSection.BookIndex.FemaleTopAd,     //顶部广告位
                           MiddleAD        = RecSection.BookIndex.FemaleMiddleAd   //中间广告位
                       }
            };
        }

        #endregion 辅助方法
    }
Beispiel #3
0
 private dynamic GetRecClass(Constants.Novel.ClassSpeType speType)
 {
     if (speType == Constants.Novel.ClassSpeType.male)
     {
         return new
                {
                    New   = RecSection.LimitFree.MaleNewRec,
                    Hot   = RecSection.LimitFree.MaleHotRec,
                    Limit = RecSection.LimitFree.MaleIndexRec
                }
     }
     ;
     else
     {
         return new
                {
                    New   = RecSection.LimitFree.FemaleNewRec,
                    Hot   = RecSection.LimitFree.FemaleHotRec,
                    Limit = RecSection.LimitFree.FemaleIndexRec
                }
     };
 }
Beispiel #4
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));
        }