コード例 #1
0
        public JsonResult GetHomepage()
        {
            Response.Filter = new GZipStream(Response.Filter, CompressionMode.Compress);
            string jsonString = String.Empty;
            SynapseHomepage homepage = null;
            try
            {
                var countryCode = MyUtility.GetCurrentCountryCodeOrDefault();
                var cache = DataCache.Cache;
                string cacheKey = "SYNAPSEGHOMEPAGE:O:;C:" + countryCode;
                try { jsonString = (string)cache[cacheKey]; }
                catch (Exception) { }
                if (String.IsNullOrEmpty(jsonString))
                {
                    homepage = new SynapseHomepage();
                    var context = new IPTV2Entities();
                    List<FeatureItem> featureItems = null;
                    var featuredShows = context.Features.FirstOrDefault(f => f.FeatureId == GlobalConfig.LatestShows && f.StatusId == GlobalConfig.Visible);
                    if (featuredShows != null)
                    {
                        List<SynapseShow> shows = new List<SynapseShow>();
                        var fItems = featuredShows.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible);
                        if (fItems != null)
                        {
                            featureItems = fItems.ToList();
                            foreach (var f in featureItems)
                            {
                                if (f is ShowFeatureItem)
                                {
                                    ShowFeatureItem sft = (ShowFeatureItem)f;
                                    int parentId = 0;
                                    string parent = String.Empty;
                                    Show show = sft.Show;
                                    if (show.IsMobileAllowed(countryCode))
                                    {
                                        foreach (var item in show.ParentCategories.Where(p => p.CategoryId != GlobalConfig.FreeTvCategoryId))
                                        {
                                            parentId = item.CategoryId;
                                            parent = item.Description;
                                        }
                                        string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster);
                                        string banner = String.IsNullOrEmpty(show.ImageBanner) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImageBanner);
                                        SynapseShow s = new SynapseShow() { id = show.CategoryId, name = show.Description, blurb = show.Blurb, image = img, banner = banner, parent = parent, parentId = parentId };
                                        shows.Add(s);
                                    }
                                }
                            }
                        }
                        homepage.show = shows;
                    }

                    var featuredCelebrities = context.Features.FirstOrDefault(f => f.FeatureId == GlobalConfig.FeaturedCelebrities && f.StatusId == GlobalConfig.Visible);
                    if (featuredCelebrities != null)
                    {
                        List<SynapseCelebrity> celebrities = new List<SynapseCelebrity>();
                        var fCelebItems = featuredCelebrities.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible);
                        if (fCelebItems != null)
                        {
                            featureItems = fCelebItems.OrderByDescending(f => f.FeatureItemId).ToList();
                            foreach (var f in featureItems)
                            {
                                if (f is CelebrityFeatureItem)
                                {
                                    CelebrityFeatureItem cft = (CelebrityFeatureItem)f;
                                    Celebrity person = cft.Celebrity;
                                    string img = String.IsNullOrEmpty(person.ImageUrl) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, person.CelebrityId.ToString(), person.ImageUrl);
                                    SynapseCelebrity c = new SynapseCelebrity()
                                    {
                                        id = person.CelebrityId,
                                        name = person.FullName,
                                        image = img
                                    };
                                    celebrities.Add(c);
                                }
                            }
                        }

                        homepage.celebrity = celebrities;
                    }

                    var mainCarousel = GlobalConfig.CarouselEntertainmentId; //hard-coded
                    Carousel carousel = context.Carousels.FirstOrDefault(c => c.CarouselId == mainCarousel && c.StatusId == GlobalConfig.Visible);
                    if (carousel != null)
                    {
                        var fSlides = carousel.CarouselSlides.Where(c => c.MobileStatusId == GlobalConfig.Visible).OrderByDescending(c => c.CarouselSlideId);
                        if (fSlides != null)
                        {
                            List<CarouselSlide> slides = fSlides.ToList();
                            var random = slides.OrderBy(x => System.Guid.NewGuid()).FirstOrDefault();
                            JsonCarouselItem item = new JsonCarouselItem() { CarouselSlideId = random.CarouselSlideId, BannerImageUrl = String.Format("{0}{1}/{2}", GlobalConfig.CarouselImgPath, random.CarouselSlideId.ToString(), random.BannerImageUrl), Blurb = random.Blurb, Name = random.Name, Header = random.Header, TargetUrl = random.TargetUrl, ButtonLabel = random.ButtonLabel };
                            homepage.carousel = item;
                        }
                    }
                    var cacheDuration = new TimeSpan(0, GlobalConfig.SynapseGenericCacheDuration, 0);
                    jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(homepage);
                    cache.Put(cacheKey, jsonString, cacheDuration);
                }
                else
                    homepage = Newtonsoft.Json.JsonConvert.DeserializeObject<SynapseHomepage>(jsonString);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return Json(homepage, JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
        public JsonResult GetMovies()
        {
            Response.Filter = new GZipStream(Response.Filter, CompressionMode.Compress);

            try
            {
                var context = new IPTV2Entities();
                var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId);
                var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
                var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == GlobalConfig.Movies && c.StatusId == GlobalConfig.Visible);

                List<SynapseShow> list = new List<SynapseShow>();

                string countrycode = MyUtility.GetCurrentCountryCodeOrDefault();
                var setOfMovies = service.GetAllMobileShowIds(countrycode, (Category)category);

                var movies = context.CategoryClasses.Where(c => setOfMovies.Contains(c.CategoryId) && c.StatusId == GlobalConfig.Visible);

                if (movies != null)
                {
                    foreach (var movie in movies)
                    {
                        SynapseShow show = null;
                        if (movie is Show)
                        {
                            string type = "show";
                            var temp = (Show)movie;
                            if (temp is Movie)
                            {
                                type = "movie";
                                var eList = temp.Episodes.OrderByDescending(e => e.Episode.DateAired);
                                if (eList != null)
                                {
                                    var epList = eList.ToList();
                                    List<SynapseEpisode> episodes = new List<SynapseEpisode>();
                                    foreach (var e in epList)
                                    {
                                        string epImg = String.IsNullOrEmpty(e.Episode.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, e.Episode.EpisodeId.ToString(), e.Episode.ImageAssets.ImageVideo);
                                        SynapseEpisode episode = new SynapseEpisode() { id = e.Episode.EpisodeId, name = e.Episode.Description, dateaired = e.Episode.DateAired.Value.ToString("MMM d, yyyy"), synopsis = e.Episode.Synopsis, image = epImg };
                                        episodes.Add(episode);
                                    }
                                    string img = String.IsNullOrEmpty(temp.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, temp.CategoryId.ToString(), temp.ImagePoster);
                                    string banner = String.IsNullOrEmpty(temp.ImageBanner) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, temp.CategoryId.ToString(), temp.ImageBanner);
                                    show = new SynapseShow() { id = temp.CategoryId, name = temp.Description, blurb = temp.Blurb, image = img, banner = banner, type = type };
                                    var parentcat = temp.CategoryClassParentCategories.FirstOrDefault(c => c.ParentCategory.CategoryId != GlobalConfig.FreeTvCategoryId);
                                    show.parentId = parentcat.ParentId;
                                    show.parent = parentcat.ParentCategory.Description;
                                    show.episodes = episodes;
                                }
                                list.Add(show);
                            }
                        }
                    }
                    return this.Json(list, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return this.Json(null, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
        public JsonResult GetShowDetails(int? id, int? status)
        {
            Response.Filter = new GZipStream(Response.Filter, CompressionMode.Compress);
            if (id == null)
                id = 0;

            var context = new IPTV2Entities();
            DateTime registDt = DateTime.Now;
            var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId);
            var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
            var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id && c.StatusId == GlobalConfig.Visible);
            SynapseShow show = null;
            if (category != null)
            {
                if (category is Show)
                {
                    var countryCode = MyUtility.GetCurrentCountryCodeOrDefault();
                    var showT = (Show)category;
                    if (!showT.IsMobileAllowed(countryCode))
                        return this.Json(String.Empty, JsonRequestBehavior.AllowGet);

                    string type = "show";
                    // Check if movie
                    var temp = (Show)category;
                    int parentId = 0;
                    string parent = String.Empty;
                    foreach (var item in temp.ParentCategories.Where(p => p.CategoryId != GlobalConfig.FreeTvCategoryId))
                    {
                        if (item.CategoryClassParentCategories.Where(p => p.ParentId == GlobalConfig.Movies && p.ParentId != GlobalConfig.FreeTvCategoryId).Count() > 0)
                            type = "movie";

                        parentId = item.CategoryId;
                        parent = item.Description;

                    }

                    //IOrderedEnumerable<EpisodeCategory> eList;
                    var episodeCategories = context.EpisodeCategories1.Where(e => e.CategoryId == category.CategoryId && e.Episode.MobileStatusId == GlobalConfig.Visible).Select(e => e.EpisodeId);
                    var episodeList = context.Episodes.Where(e => episodeCategories.Contains(e.EpisodeId) && e.MobileStatusId == GlobalConfig.Visible && e.MobileStartDate < registDt && e.MobileEndDate > registDt)
                        .OrderByDescending(e => e.DateAired);

                    if (episodeList != null)
                    {
                        //var epList = eList.ToList();
                        List<SynapseEpisode> episodes = new List<SynapseEpisode>();
                        foreach (var e in episodeList)
                        {
                            string epImg = String.IsNullOrEmpty(e.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, e.EpisodeId.ToString(), e.ImageAssets.ImageVideo);
                            string EpLength = "";
                            if (!(e.EpisodeLength == null))
                            {
                                TimeSpan span = new TimeSpan(0, 0, Convert.ToInt32(e.EpisodeLength) * 60);
                                EpLength = String.Format("{0}:{1}:{2}", span.Hours.ToString().PadLeft(2, '0'), span.Minutes.ToString().PadLeft(2, '0'), span.Seconds.ToString().PadLeft(2, '0'));
                            }
                            SynapseEpisode episode = new SynapseEpisode() { id = e.EpisodeId, name = e.Description, dateaired = e.DateAired.Value.ToString("MMM d, yyyy"), synopsis = e.Synopsis, image = epImg, episodelength = EpLength, episodenumber = e.EpisodeNumber, expirydate = e.EndDate.Value.ToString("MM/dd/yyyy hh:mm:ss"), oexpirydate = e.OnlineEndDate.Value.ToString("MM/dd/yyyy hh:mm:ss"), mexpirydate = e.MobileEndDate.Value.ToString("MM/dd/yyyy hh:mm:ss"), statusid = e.MobileStatusId };
                            episodes.Add(episode);

                        }

                        string img = String.IsNullOrEmpty(category.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, category.CategoryId.ToString(), category.ImagePoster);
                        string banner = String.IsNullOrEmpty(category.ImageBanner) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, category.CategoryId.ToString(), category.ImageBanner);
                        show = new SynapseShow() { id = category.CategoryId, name = category.Description, blurb = category.Blurb, image = img, banner = banner, type = type, parent = parent, parentId = parentId };
                        show.episodes = episodes;
                    }
                }

                return this.Json(show, JsonRequestBehavior.AllowGet);
            }
            return this.Json(String.Empty, JsonRequestBehavior.AllowGet);
        }
コード例 #4
0
        public JsonResult GetShows(int? id)
        {
            Response.Filter = new GZipStream(Response.Filter, CompressionMode.Compress);
            if (id == null)
                id = 0;
            var cache = DataCache.Cache;
            string jsonString = String.Empty;
            SynapseCategory cat = null;
            var countryCode = MyUtility.GetCurrentCountryCodeOrDefault();
            string cacheKey = "SYNAPGTSHOWS:0;C:" + id + ";CC:" + countryCode;
            try { jsonString = (string)cache[cacheKey]; }
            catch (Exception) { }
            if (String.IsNullOrEmpty(jsonString))
            {
                cat = new SynapseCategory();
                var context = new IPTV2Entities();
                var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId);
                var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
                var categoryClass = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == (int)id && c.StatusId == GlobalConfig.Visible);
                if (categoryClass != null)
                {
                    if (categoryClass is Category)
                    {
                        Category category = (Category)categoryClass;
                        SortedSet<int> showIds = service.GetAllMobileShowIds(countryCode, category);
                        ViewBag.Category = category.Description;
                        int[] setofShows = showIds.ToArray();
                        var list = context.CategoryClasses.Where(c => setofShows.Contains(c.CategoryId) && c.StatusId == GlobalConfig.Visible).OrderBy(c => c.CategoryName).ThenBy(c => c.StartDate).ToList();
                        var random = list.OrderBy(x => System.Guid.NewGuid()).FirstOrDefault();
                        cat.id = category.CategoryId;
                        cat.name = category.Description;
                        string featuredImg = String.IsNullOrEmpty(random.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, random.CategoryId.ToString(), random.ImagePoster);
                        string featuredBanner = String.IsNullOrEmpty(random.ImageBanner) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, random.CategoryId.ToString(), random.ImageBanner);
                        SynapseShow feature = new SynapseShow() { id = random.CategoryId, name = random.Description, blurb = random.Blurb, image = featuredImg, banner = featuredBanner, dateairedstr = random.StartDate.Value.ToString("yyyy") };

                        cat.feature = feature;
                        List<SynapseShow> shows = new List<SynapseShow>();

                        foreach (var item in list)
                        {
                            if (item is Show)
                            {
                                string img = String.IsNullOrEmpty(item.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, item.CategoryId.ToString(), item.ImagePoster);
                                string banner = String.IsNullOrEmpty(item.ImageBanner) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, item.CategoryId.ToString(), item.ImageBanner);
                                SynapseShow show = new SynapseShow() { id = item.CategoryId, name = item.Description, blurb = item.Blurb, image = img, banner = banner, dateairedstr = item.StartDate.Value.ToString("yyyy") };
                                shows.Add(show);
                            }
                        }
                        cat.shows = shows;
                    }
                }
                var cacheDuration = new TimeSpan(0, GlobalConfig.SynapseGenericCacheDuration, 0);
                jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(cat);
                cache.Put(cacheKey, jsonString, cacheDuration);
            }
            else
                cat = Newtonsoft.Json.JsonConvert.DeserializeObject<SynapseCategory>(jsonString);
            return Json(cat, JsonRequestBehavior.AllowGet);
        }
コード例 #5
0
        private void FillCategoriesWithShows(IPTV2Entities context, TimeSpan cacheDuration, IEnumerable<int> categoryIds, int offeringId, int serviceId)
        {
            var countries = context.Countries;
            foreach (int categoryId in categoryIds)
            {
                try
                {
                    foreach (var cx in countries)
                    {
                        string cacheKey = "SYNAPGTSHOWS:0;C:" + categoryId + ";CC:" + cx.Code;
                        SynapseCategory cat = new SynapseCategory();
                        var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == offeringId);
                        var service = offering.Services.FirstOrDefault(s => s.PackageId == serviceId);
                        var categoryClass = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == categoryId && c.StatusId == Visible);
                        if (categoryClass != null)
                        {
                            if (categoryClass is Category)
                            {
                                Category category = (Category)categoryClass;
                                SortedSet<int> showIds = service.GetAllMobileShowIds(cx.Code, category);

                                int[] setofShows = showIds.ToArray();
                                var list = context.CategoryClasses.Where(c => setofShows.Contains(c.CategoryId) && c.StatusId == Visible).OrderBy(c => c.CategoryName).ThenBy(c => c.StartDate).ToList();
                                var random = list.OrderBy(x => System.Guid.NewGuid()).FirstOrDefault();
                                cat.id = category.CategoryId;
                                cat.name = category.Description;
                                string featuredImg = String.IsNullOrEmpty(random.ImagePoster) ? AssetsBaseUrl + BlankGif : String.Format("{0}{1}/{2}", ShowImgPath, random.CategoryId.ToString(), random.ImagePoster);
                                string featuredBanner = String.IsNullOrEmpty(random.ImageBanner) ? AssetsBaseUrl + BlankGif : String.Format("{0}{1}/{2}", ShowImgPath, random.CategoryId.ToString(), random.ImageBanner);
                                SynapseShow feature = new SynapseShow() { id = random.CategoryId, name = random.Description, blurb = random.Blurb, image = featuredImg, banner = featuredBanner, dateairedstr = random.StartDate.Value.ToString("yyyy") };
                                cat.feature = feature;
                                List<SynapseShow> shows = new List<SynapseShow>();
                                foreach (var item in list)
                                {
                                    if (item is Show)
                                    {
                                        string img = String.IsNullOrEmpty(item.ImagePoster) ? AssetsBaseUrl + BlankGif : String.Format("{0}{1}/{2}", ShowImgPath, item.CategoryId.ToString(), item.ImagePoster);
                                        string banner = String.IsNullOrEmpty(item.ImageBanner) ? AssetsBaseUrl + BlankGif : String.Format("{0}{1}/{2}", ShowImgPath, item.CategoryId.ToString(), item.ImageBanner);
                                        SynapseShow show = new SynapseShow() { id = item.CategoryId, name = item.Description, blurb = item.Blurb, image = img, banner = banner, dateairedstr = item.StartDate.Value.ToString("yyyy") };
                                        shows.Add(show);
                                    }
                                }
                                cat.shows = shows;
                            }
                        }
                        DataCache.Cache.Put(cacheKey, cat, cacheDuration);
                    }
                }
                catch (Exception e) { Trace.TraceError("FillCategoryWithShows Cache - Error! " + e.Message); }
            }
        }
コード例 #6
0
        private void FillHomePage(IPTV2Entities context, TimeSpan cacheDuration)
        {
            var countries = context.Countries;
            foreach (var cx in countries)
            {
                try
                {
                    string cacheKey = "SYNAPSEGHOMEPAGE:O:;C:" + cx.Code;
                    SynapseHomepage homepage = new SynapseHomepage();
                    List<FeatureItem> featureItems = null;
                    var featuredShows = context.Features.FirstOrDefault(f => f.FeatureId == LatestShows && f.StatusId == Visible);
                    if (featuredShows != null)
                    {
                        List<SynapseShow> shows = new List<SynapseShow>();
                        var fItems = featuredShows.FeatureItems.Where(f => f.StatusId == Visible);
                        if (fItems != null)
                        {
                            featureItems = fItems.ToList();
                            foreach (var f in featureItems)
                            {
                                if (f is ShowFeatureItem)
                                {
                                    ShowFeatureItem sft = (ShowFeatureItem)f;
                                    int parentId = 0;
                                    string parent = String.Empty;
                                    Show show = sft.Show;
                                    if (show.IsMobileAllowed(cx.Code))
                                    {
                                        foreach (var item in show.ParentCategories.Where(p => p.CategoryId != FreeTvCategoryId))
                                        {
                                            parentId = item.CategoryId;
                                            parent = item.Description;

                                        }
                                        string img = String.IsNullOrEmpty(show.ImagePoster) ? AssetsBaseUrl + BlankGif : String.Format("{0}{1}/{2}", ShowImgPath, show.CategoryId.ToString(), show.ImagePoster);
                                        string banner = String.IsNullOrEmpty(show.ImageBanner) ? AssetsBaseUrl + BlankGif : String.Format("{0}{1}/{2}", ShowImgPath, show.CategoryId.ToString(), show.ImageBanner);
                                        SynapseShow s = new SynapseShow() { id = show.CategoryId, name = show.Description, blurb = show.Blurb, image = img, banner = banner, parent = parent, parentId = parentId };
                                        shows.Add(s);
                                    }
                                }
                            }
                        }

                        homepage.show = shows;
                    }

                    var featuredCelebrities = context.Features.FirstOrDefault(f => f.FeatureId == FeaturedCelebrities && f.StatusId == Visible);
                    if (featuredCelebrities != null)
                    {
                        List<SynapseCelebrity> celebrities = new List<SynapseCelebrity>();
                        var fCelebItems = featuredCelebrities.FeatureItems.Where(f => f.StatusId == Visible);
                        if (fCelebItems != null)
                        {
                            featureItems = fCelebItems.ToList();
                            foreach (var f in featureItems)
                            {
                                if (f is CelebrityFeatureItem)
                                {
                                    CelebrityFeatureItem cft = (CelebrityFeatureItem)f;
                                    Celebrity person = cft.Celebrity;
                                    string img = String.IsNullOrEmpty(person.ImageUrl) ? AssetsBaseUrl + BlankGif : String.Format("{0}{1}/{2}", CelebrityImgPath, person.CelebrityId.ToString(), person.ImageUrl);
                                    SynapseCelebrity c = new SynapseCelebrity()
                                    {
                                        id = person.CelebrityId,
                                        name = person.FullName,
                                        image = img
                                    };
                                    celebrities.Add(c);
                                }
                            }
                        }

                        homepage.celebrity = celebrities;
                    }

                    var mainCarousel = CarouselEntertainmentId; //hard-coded
                    Carousel carousel = context.Carousels.FirstOrDefault(c => c.CarouselId == mainCarousel && c.StatusId == Visible);
                    if (carousel != null)
                    {
                        var fSlides = carousel.CarouselSlides.Where(c => c.MobileStatusId == Visible).OrderByDescending(c => c.CarouselSlideId);
                        if (fSlides != null)
                        {
                            List<CarouselSlide> slides = fSlides.ToList();
                            var random = slides.OrderBy(x => System.Guid.NewGuid()).FirstOrDefault();
                            JsonCarouselItem item = new JsonCarouselItem() { CarouselSlideId = random.CarouselSlideId, BannerImageUrl = String.Format("{0}{1}/{2}", CarouselImgPath, random.CarouselSlideId.ToString(), random.BannerImageUrl), Blurb = random.Blurb, Name = random.Name, Header = random.Header, TargetUrl = random.TargetUrl, ButtonLabel = random.ButtonLabel };
                            homepage.carousel = item;
                        }
                    }

                    var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(homepage);                    
                    DataCache.Cache.Put(cacheKey, jsonString, cacheDuration);
                }
                catch (Exception e) { Trace.TraceError("FillHomePage Cache - Error! " + e.Message); }
            }
        }