/// <summary> /// 获取首页所有相关Banner /// </summary> /// <returns></returns> public static HomBannersVM GetHomeBanners(int sliderCount = 5, int middleItemCount = 5, int bottomItemCount = 5) { PageType pageType = PageType.Home; int pageID = 0; string cacheKey = CommonFacade.GenerateKey("GetBannerInfoOfHome", pageType.ToString(), pageID.ToString()); if (HttpRuntime.Cache[cacheKey] != null) { return((HomBannersVM)HttpRuntime.Cache[cacheKey]); } List <BannerInfo> bannerInfoList = RecommendDA.GetBannerInfoByPositionID(pageID, pageType, null); HomBannersVM result = new HomBannersVM(); //首页轮播广告 result.Sliders = bannerInfoList.Where(item => item.PositionID == BannerPosition.HomePage_Top_Slider).Take(sliderCount).ToList(); //新闻公告下部 result.UnderNews = bannerInfoList.FirstOrDefault(item => item.PositionID == BannerPosition.HomePage_UnderNews); //首页底部精选品牌 result.Bottom = bannerInfoList.Where(item => item.PositionID == BannerPosition.HomePage_Bottom).Take(bottomItemCount).ToList(); HttpRuntime.Cache.Insert(cacheKey, result, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(result); }
public static List <BannerInfo> GetBannerInfoByPositionID(int pageID, PageType pageType, BannerPosition positionID) { string cacheKey = CommonFacade.GenerateKey("GetBannerInfoByPositionID", pageType.ToString(), pageID.ToString(), positionID.ToString()); if (HttpRuntime.Cache[cacheKey] != null) { return((List <BannerInfo>)HttpRuntime.Cache[cacheKey]); } List <BannerInfo> bannerInfoList = RecommendDA.GetBannerInfoByPositionID(pageID, pageType, positionID); HttpRuntime.Cache.Insert(cacheKey, bannerInfoList, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration); return(bannerInfoList); }