public PartialViewResult GetPlayList(int? id) { var context = new IPTV2Entities(); if (id == null) { id = GlobalConfig.FreeTVPlayListId; } var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); if (feature == null) return null; List<FeatureItem> featureItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible).ToList(); List<JsonFeatureItem> jfi = new List<JsonFeatureItem>(); foreach (EpisodeFeatureItem f in featureItems) { if (f is EpisodeFeatureItem) { Episode ep = context.Episodes.Find(f.EpisodeId); if (ep != null) { Show show = ep.EpisodeCategories.FirstOrDefault(e => e.CategoryId != GlobalConfig.FreeTvCategoryId).Show; if (show != null) { string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = ep.Description, EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = show.CategoryName, EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = MyUtility.Ellipsis(ep.Synopsis, 80) }; jfi.Add(j); } } } } ViewBag.FeaturedId = id; return PartialView("_GetPlayList", jfi); }
public JsonResult GetFeaturedShow(int id) { var context = new IPTV2Entities(); var featureItems = context.Features.Find(id).FeatureItems.ToList(); List<JsonFeatureItem> jfi = new List<JsonFeatureItem>(); foreach (ShowFeatureItem f in featureItems) { if (f is ShowFeatureItem) { Show show = f.Show; JsonFeatureItem j = new JsonFeatureItem() { ShowId = show.CategoryId, ShowName = show.Description, ShowDescription = show.Description, ShowImageUrl = String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster) }; jfi.Add(j); } } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetLatestUAAPGameEpisodes() { List<JsonFeatureItem> jfi = null; DateTime registDt = DateTime.Now; var cache = DataCache.Cache; string cacheKey = "NadsUaapLatestGameCacKey"; jfi = (List<JsonFeatureItem>)cache[cacheKey]; try { if (jfi == null) { var context = new IPTV2Entities(); var feature = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == GlobalConfig.SpecialElectionCoverageCategoryId && c.StatusId == GlobalConfig.Visible); if (feature == null) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); if (!(feature is Show)) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); if (feature.StartDate > registDt) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); if (feature.EndDate < registDt) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); //List<FeatureItem> featureItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.AuditTrail.UpdatedOn).ToList(); var episodeIds = context.EpisodeCategories1.Where(e => e.CategoryId == feature.CategoryId).Select(e => e.EpisodeId); var featureItems = context.Episodes.Where(e => episodeIds.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible).OrderByDescending(e => e.EpisodeId).ThenByDescending(e => e.AuditTrail.UpdatedBy); jfi = new List<JsonFeatureItem>(); Show show = (Show)feature; foreach (var f in featureItems) { if (f is Episode) { if (f.OnlineStartDate < registDt && f.OnlineEndDate > registDt) { string img = String.IsNullOrEmpty(f.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, f.EpisodeId.ToString(), f.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = f.EpisodeId, EpisodeDescription = MyUtility.Ellipsis(f.Description, 20), EpisodeName = f.EpisodeName, EpisodeAirDate = (f.DateAired != null) ? f.DateAired.Value.ToString("MMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = String.Compare(f.EpisodeName, f.EpisodeCode) == 0 ? MyUtility.Ellipsis(show.CategoryName, 20) : MyUtility.Ellipsis(f.EpisodeName, 20), EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = MyUtility.Ellipsis(f.Synopsis, 80) }; if (jfi.Count() < GlobalConfig.SpecialElectionCoverageEpisodeDisplayCount) jfi.Add(j); else break; } } } cache.Put(cacheKey, jfi, DataCache.CacheDuration); } return this.Json(jfi, JsonRequestBehavior.AllowGet); } catch (Exception e) { MyUtility.LogException(e); return this.Json(string.Empty, JsonRequestBehavior.AllowGet); } }
public JsonResult GetFeaturedTeams() { List<JsonFeatureItem> jfi = null; var cache = DataCache.Cache; string cacheKey = "UAAPTEAMSMENUCACHEKEY:0;"; jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == 82 && f.StatusId == GlobalConfig.Visible); if (feature == null) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); List<FeatureItem> featureItems = feature.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.AuditTrail.UpdatedOn).ToList(); jfi = new List<JsonFeatureItem>(); foreach (CelebrityFeatureItem f in featureItems) { if (f is CelebrityFeatureItem) { Celebrity person = f.Celebrity; string img = String.IsNullOrEmpty(person.ImageUrl) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, person.CelebrityId.ToString(), person.ImageUrl); JsonFeatureItem j = new JsonFeatureItem() { CelebrityFullName = person.FullName, ShowId = person.CelebrityId, ShowImageUrl = img, EpisodeName = person.Height }; jfi.Add(j); } } var cacheDuration = new TimeSpan(0, GlobalConfig.MenuCacheDuration, 0); cache.Put(cacheKey, jfi, DataCache.CacheDuration); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public ActionResult GetEpisodeInfo(int id) { var context = new IPTV2Entities(); EpisodeCategory epicat = context.EpisodeCategories1.FirstOrDefault(e => e.EpisodeId == id); JsonFeatureItem js = new JsonFeatureItem(); js.EpisodeId = epicat.Episode.EpisodeId; js.EpisodeDescription = epicat.Episode.Description; js.ShowId = epicat.Show.CategoryId; js.ShowDescription = epicat.Show.Description; js.EpisodeAirDate = string.Format("{0: MMMM d,yyyy }", epicat.Episode.DateAired); return this.Json(js, JsonRequestBehavior.AllowGet); }
//public const int PageSize = 10; //[OutputCache(NoStore = true, Duration = 0)] //public BinaryResult _GetClip(int? id) //{ // //if (String.IsNullOrEmpty(Request.UrlReferrer.AbsoluteUri)) // // return RedirectToAction("Index", "Home"); // Dictionary<string, object> collection = new Dictionary<string, object>(); // ErrorCodes errorCode = ErrorCodes.UnknownError; // string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError); // collection = MyUtility.setError(errorCode, errorMessage); // var context = new IPTV2Entities(); // Episode ep = context.Episodes.FirstOrDefault(e => e.EpisodeId == id && e.OnlineStatusId == GlobalConfig.Visible); // if (ep != null) // { // Asset asset = ep.PremiumAssets.FirstOrDefault().Asset; // if (asset != null) // { // int assetId = asset == null ? 0 : asset.AssetId; // ViewBag.AssetId = assetId; // var clipDetails = Helpers.Akamai.GetAkamaiClipDetails(ep.EpisodeId, assetId, Request, User); // if (!String.IsNullOrEmpty(clipDetails.Url)) // { // errorCode = ErrorCodes.Success; // collection = MyUtility.setError(errorCode, clipDetails.Url); // collection.Add("data", clipDetails); // } // else // { // errorCode = ErrorCodes.AkamaiCdnNotFound; // collection = MyUtility.setError(errorCode, "Akamai Url not found."); // } // } // else // { // errorCode = ErrorCodes.VideoNotFound; // collection = MyUtility.setError(errorCode, "Video not found."); // } // } // else // { // errorCode = ErrorCodes.EpisodeNotFound; // collection = MyUtility.setError(errorCode, "Episode not found."); // } // byte[] jsonToBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(MyUtility.buildJson(collection)); // return new BinaryResult() // { // ContentType = "application/octet-stream", // IsAttachment = false, // Data = jsonToBytes // }; //} //[OutputCache(NoStore = true, Duration = 0)] //public string _GetClip2(int? id) //{ // //if (String.IsNullOrEmpty(Request.UrlReferrer.AbsoluteUri)) // // return RedirectToAction("Index", "Home"); // Dictionary<string, object> collection = new Dictionary<string, object>(); // ErrorCodes errorCode = ErrorCodes.UnknownError; // string errorMessage = MyUtility.getErrorMessage(ErrorCodes.UnknownError); // collection = MyUtility.setError(errorCode, errorMessage); // var context = new IPTV2Entities(); // Episode ep = context.Episodes.FirstOrDefault(e => e.EpisodeId == id && e.OnlineStatusId == GlobalConfig.Visible); // string url = ""; // if (ep != null) // { // Asset asset = ep.PremiumAssets.FirstOrDefault().Asset; // if (asset != null) // { // int assetId = asset == null ? 0 : asset.AssetId; // ViewBag.AssetId = assetId; // var clipDetails = Helpers.Akamai.GetAkamaiClipDetails(ep.EpisodeId, assetId, Request, User); // if (!String.IsNullOrEmpty(clipDetails.Url)) // { // errorCode = ErrorCodes.Success; // collection = MyUtility.setError(errorCode, clipDetails.Url); // collection.Add("data", clipDetails); // url = clipDetails.Url; // } // else // { // errorCode = ErrorCodes.AkamaiCdnNotFound; // collection = MyUtility.setError(errorCode, "Akamai Url not found."); // } // } // else // { // errorCode = ErrorCodes.VideoNotFound; // collection = MyUtility.setError(errorCode, "Video not found."); // } // } // else // { // errorCode = ErrorCodes.EpisodeNotFound; // collection = MyUtility.setError(errorCode, "Episode not found."); // } // WebClient client = new WebClient(); // Stream data = client.OpenRead(url); // StreamReader reader = new StreamReader(data); // string s = reader.ReadToEnd(); // data.Close(); // reader.Close(); // return s; //} //public ActionResult List() //{ // return View(); //} /// <summary> /// Description: Get Episodes List /// </summary> /// <param name="page"></param> /// <returns></returns> public ActionResult GetEpisodes(int page, int pagesize) { var episode_data = new PagedData<JsonFeatureItem>(); List<JsonFeatureItem> episode_list = new List<JsonFeatureItem>(); var context = new IPTV2Entities(); //List<ShowLookUpObject> sluo = (List<ShowLookUpObject>)HttpContext.Cache["ShowList"]; List<Show> showslist = new List<Show>(); List<int> dummy = new List<int>(); int[] showIds; var service = context.Offerings.Find(GlobalConfig.offeringId).Services .Where(p => p.PackageId == GlobalConfig.serviceId && p.StatusId == GlobalConfig.Visible).Single(); foreach (var category in service.Categories.Select(p => p.Category)) { //get shows foreach (int i in service.GetAllOnlineShowIds("--", category).ToArray()) { dummy.Add(i); } } showIds = dummy.ToArray(); int records = context.EpisodeCategories1 .Where( e => showIds.Contains(e.CategoryId) && e.Episode.OnlineStatusId == GlobalConfig.Visible ) .Select(n => n.Episode).Count(); foreach (var item in context.EpisodeCategories1 .Where( e => showIds.Contains(e.CategoryId) ) .Select(n => n.Episode).OrderBy(n => n.EpisodeName).Skip(pagesize * (page - 1)) .Take(pagesize).ToList()) { JsonFeatureItem EpisodeItem = new JsonFeatureItem(); EpisodeItem.EpisodeName = item.EpisodeName; EpisodeItem.EpisodeAirDate = (item.DateAired != null) ? item.DateAired.Value.ToString("MMMM d, yyyy") : ""; EpisodeItem.EpisodeDescription = item.Description; EpisodeItem.EpisodeImageUrl = item.ImageAssets.ImageMedium; EpisodeItem.ShowId = item.EpisodeCategories.Single().Show.CategoryId; EpisodeItem.ShowName = item.EpisodeCategories.Single().Show.CategoryName; EpisodeItem.ShowImageUrl = item.EpisodeCategories.Single().Show.ImageTitle; EpisodeItem.EpisodeId = item.EpisodeId; episode_list.Add(EpisodeItem); } episode_data.Data = episode_list; episode_data.NumberOfPages = Convert.ToInt32(Math.Ceiling((double)records / pagesize)); episode_data.CurrentPage = page; ViewBag.EpisodeList = episode_data; return Json(episode_data, JsonRequestBehavior.AllowGet); }
/// <summary> /// Description: Gets the list of episodes to be used for the FeatureSlides (Latest Full Episodes, Most Viewed, Free TV) /// </summary> /// <param name="id"></param> /// <returns></returns> //[OutputCache(VaryByParam = "id", Duration = 180)] public JsonResult GetCarousel(int id) { var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); if (feature == null) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); var fItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); List<JsonFeatureItem> jfi = new List<JsonFeatureItem>(); if (fItems != null) { List<FeatureItem> featureItems = fItems.ToList(); foreach (EpisodeFeatureItem f in featureItems) { if (f is EpisodeFeatureItem) { Episode ep = context.Episodes.FirstOrDefault(e => e.EpisodeId == f.EpisodeId && e.MobileStatusId == GlobalConfig.Visible); if (ep != null) { Show show = ep.EpisodeCategories.FirstOrDefault().Show; if (show != null) { int parentId = 0; string parent = String.Empty; foreach (var item in show.ParentCategories.Where(p => p.CategoryId != GlobalConfig.FreeTvCategoryId)) { parent = item.Description; parentId = item.CategoryId; } string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); string bannerImg = String.IsNullOrEmpty(show.ImageBanner) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId, show.ImageBanner); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = MyUtility.Ellipsis(ep.Description, 20), EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = MyUtility.Ellipsis(show.CategoryName, 20), EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = MyUtility.Ellipsis(ep.Synopsis, 80), ShowBannerUrl = bannerImg, parentId = parentId, parent = parent }; jfi.Add(j); } } } } } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetTeamGameEpisodes(int? id) { List<JsonFeatureItem> jfi = null; if (id != null) { var registDt = DateTime.Now; var cache = DataCache.Cache; string cacheKey = "UAAPGTGES:0;" + id; jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { jfi = new List<JsonFeatureItem>(); var context = new IPTV2Entities(); var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == id); if (celebrity != null) { var gamesCategoryIds = celebrity.ShowCelebrityRoles.Where(celeb => celeb.CelebrityId == celebrity.CelebrityId).Select(s => s.CategoryId); var episodeIds = context.EpisodeCategories1.Where(e => gamesCategoryIds.Contains(e.CategoryId)).Select(e => e.EpisodeId); var episodes = context.Episodes.Where(e => episodeIds.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible && e.OnlineStartDate < registDt && e.OnlineEndDate > registDt); foreach (var ep in episodes) { var episodeCategory = ep.EpisodeCategories.FirstOrDefault(e => e.CategoryId != GlobalConfig.FreeTvCategoryId); var show = episodeCategory.Show; var name = show.Description; string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = MyUtility.Ellipsis(ep.Description, 20), EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = MyUtility.Ellipsis(show.CategoryName, 20), EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = MyUtility.Ellipsis(ep.Synopsis, 80) }; jfi.Add(j); } cache.Put(cacheKey, jfi, DataCache.CacheDuration); } } } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetFeaturedPerson(int id) { List<JsonFeatureItem> jfi = null; var cache = DataCache.Cache; string cacheKey = "JRGFP:U:" + id.ToString() + ";C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode(); jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); List<FeatureItem> featureItems = feature.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.AuditTrail.UpdatedOn).ToList(); if (feature == null) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); jfi = new List<JsonFeatureItem>(); foreach (CelebrityFeatureItem f in featureItems) { if (f is CelebrityFeatureItem) { Celebrity person = f.Celebrity; JsonFeatureItem j = new JsonFeatureItem() { CelebrityFullName = person.FullName, ShowId = person.CelebrityId, ShowImageUrl = String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, person.CelebrityId.ToString(), person.ImageUrl) }; jfi.Add(j); } } cache.Put(cacheKey, jfi, DataCache.CacheDuration); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetCelebrityEpisodes(int id) { var context = new IPTV2Entities(); var celebrity = context.Celebrities.Find(id); var registDt = DateTime.Now; var obj = celebrity.EpisodeCelebrityRoles.Where(celeb => celeb.CelebrityId == celebrity.CelebrityId).Select(s => s.Episode).ToList(); List<JsonFeatureItem> jfi = new List<JsonFeatureItem>(); foreach (var ep in obj) { if (ep.OnlineStatusId == GlobalConfig.Visible) { if (ep.OnlineStartDate < registDt && ep.OnlineEndDate > registDt) { var episodeCategory = ep.EpisodeCategories.FirstOrDefault(e => e.CategoryId != GlobalConfig.FreeTvCategoryId); var show = episodeCategory.Show; var name = show.Description; string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = MyUtility.Ellipsis(ep.Description, 20), EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = MyUtility.Ellipsis(show.CategoryName, 20), EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = MyUtility.Ellipsis(ep.Synopsis, 80) }; jfi.Add(j); } } } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetPreviewEpisodes(int? id) { List<JsonFeatureItem> list = null; if (id != null) { var cache = DataCache.Cache; string cacheKey = "CATGPEKS:O:" + id; list = (List<JsonFeatureItem>)cache[cacheKey]; if (list == null) { try { DateTime registDt = DateTime.Now; var context = new IPTV2Entities(); var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id); if (category != null) { if (category is Show) { Show show = (Show)category; var episodesCats = context.EpisodeCategories1.Where(e => e.CategoryId == id).Select(ec => ec.EpisodeId); var episodes = context.Episodes.Where(e => episodesCats.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible && e.OnlineStartDate < registDt && e.OnlineEndDate > registDt) .OrderByDescending(ec => ec.DateAired).Take(2); if (episodes != null) { var epCount = episodes.Count(); var lengthOfBlurb = epCount > 1 ? GlobalConfig.MenuShowBlurbLength : GlobalConfig.MenuMovieBlurbLength; list = new List<JsonFeatureItem>(); foreach (var ep in episodes) { string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId, ep.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId, show.ImagePoster); var obj = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, Blurb = epCount > 1 || (show is LiveEvent) ? MyUtility.Ellipsis(ep.Synopsis, lengthOfBlurb) : MyUtility.Ellipsis(show.Blurb, lengthOfBlurb), EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMMM d, yyyy") : "", EpisodeImageUrl = img, ShowImageUrl = showImg }; list.Add(obj); } cache.Put(cacheKey, list, DataCache.CacheDuration); } } } } catch (Exception e) { MyUtility.LogException(e); } } } return Json(list, JsonRequestBehavior.AllowGet); }
public JsonResult GetPaginatedExclusiveList() { List<JsonFeatureItem> jfi = null; jfi = new List<JsonFeatureItem>(); var context = new IPTV2Entities(); SortedSet<int> episodeids = new SortedSet<int>(); var registDt = DateTime.Now; List<Episode> episodes = new List<Episode>(); var featureItems = context.FeatureItems.Where(f => f.FeatureId == GlobalConfig.TFCkatExclusivesCategoryId && f.StatusId == GlobalConfig.Visible).Take(12); foreach (var item in featureItems) { if (item is EpisodeFeatureItem) { var episodeFeatureItem = (EpisodeFeatureItem)item; var ep = episodeFeatureItem.Episode; string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = ep.Description, EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMM d, yyyy") : "", EpisodeImageUrl = img }; jfi.Add(j); } } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetPaginatedEpisodeList() { List<JsonFeatureItem> jfi = null; jfi = new List<JsonFeatureItem>(); var context = new IPTV2Entities(); SortedSet<int> episodeids = new SortedSet<int>(); var registDt = DateTime.Now; var episodeIDList = context.EpisodeCategories1.Where(e => e.CategoryId == GlobalConfig.TFCkatCategoryId).Select(e => e.Episode.EpisodeId); int epCount = episodeIDList.Count(); var episodeList = context.Episodes.Where(e => episodeIDList.Contains(e.EpisodeId) && e.StatusId == GlobalConfig.Visible); foreach (var ep in episodeList) { string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = MyUtility.Ellipsis(ep.Synopsis, 160), EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMM d, yyyy") : "", EpisodeImageUrl = img }; jfi.Add(j); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetPaginatedEpisodeList() { List<JsonFeatureItem> jfi = null; var cache = DataCache.Cache; string cacheKey = "UAAPPaginatedEP"; jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { jfi = new List<JsonFeatureItem>(); var context = new IPTV2Entities(); SortedSet<int> episodeids = new SortedSet<int>(); var registDt = DateTime.Now; var service = context.Offerings.Find(GlobalConfig.offeringId).Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId); var cats = (Category)context.CategoryClasses.Find(GlobalConfig.UAAPGamesParentId); var listOfShows = service.GetAllOnlineShowIds(GlobalConfig.DefaultCountry, cats); var episodeIds = context.EpisodeCategories1.Where(e => listOfShows.Contains(e.CategoryId)).Select(e => e.EpisodeId); var episodeList = context.Episodes.Where(e => episodeIds.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible && e.OnlineStartDate < registDt && e.OnlineEndDate > registDt).Take(12).OrderByDescending(e => e.DateAired).ThenBy(e => e.AuditTrail.CreatedOn); foreach (var ep in episodeList) { string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = ep.Description, EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMM d, yyyy") : "", EpisodeImageUrl = img }; jfi.Add(j); } cache.Put(cacheKey, jfi, DataCache.CacheDuration); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetEventCelebritiesFeature(int id) { var socialContext = new EngagementsEntities(); List<JsonFeatureItem> jfi = null; var cache = DataCache.Cache; string cacheKey = "EVENTFEATUREDCELEBCACHEKEY:0;"; jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); if (feature == null) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); List<FeatureItem> featureItems = feature.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.AuditTrail.UpdatedOn).ToList(); jfi = new List<JsonFeatureItem>(); foreach (var f in featureItems) { if (f is CelebrityFeatureItem) { var 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); var lovesCountSummary = socialContext.CelebrityReactionSummaries.FirstOrDefault(i => i.CelebrityId == person.CelebrityId && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE); int love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total); JsonFeatureItem j = new JsonFeatureItem() { CelebrityFullName = person.FullName, ShowId = person.CelebrityId, ShowImageUrl = img, EpisodeName = person.ZodiacSign, EpisodeDescription = love.ToString(), ShowDescription = person.ChineseYear, parentId = love }; jfi.Add(j); } } var CacheDuration = new TimeSpan(0, 30, 0); jfi = jfi.OrderByDescending(j => j.parentId).ToList(); cache.Put(cacheKey, jfi, CacheDuration); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetCelebrities() { var context = new IPTV2Entities(); var celebrities = context.Celebrities.ToList().OrderBy(celeb => celeb.FirstName); List<JsonFeatureItem> jfi = new List<JsonFeatureItem>(); foreach (Celebrity celebrity in celebrities) { string celebrityImg = String.IsNullOrEmpty(celebrity.ImageUrl) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, celebrity.CelebrityId, celebrity.ImageUrl); JsonFeatureItem j = new JsonFeatureItem() { CelebrityFullName = celebrity.FullName, ShowDescription = celebrity.FirstName + "-" + celebrity.LastName, ShowId = celebrity.CelebrityId, ShowImageUrl = celebrityImg }; jfi.Add(j); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetListingShow(int id) { List<JsonFeatureItem> jfi = null; var cache = DataCache.Cache; string cacheKey = "JRGLS:U:" + id.ToString() + ";C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode(); jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); if (feature == null) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); List<FeatureItem> featureItems = feature.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.AuditTrail.UpdatedOn).ToList(); jfi = new List<JsonFeatureItem>(); foreach (ShowFeatureItem f in featureItems) { if (f is ShowFeatureItem) { Show show = f.Show; string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); JsonFeatureItem j = new JsonFeatureItem() { ShowId = show.CategoryId, ShowName = show.Description, ShowDescription = show.Description, ShowImageUrl = img }; jfi.Add(j); } } cache.Put(cacheKey, jfi, DataCache.CacheDuration); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetCelebrityShows(int id) { var context = new IPTV2Entities(); var celebrity = context.Celebrities.Find(id); var registDt = DateTime.Now; List<JsonFeatureItem> jfi = null; try { var obj = celebrity.ShowCelebrityRoles.Where(celeb => celeb.CelebrityId == celebrity.CelebrityId).Select(s => s.Show); if (obj != null) { jfi = new List<JsonFeatureItem>(); foreach (Show show in obj.OrderByDescending(s => s.StartDate)) { if (show is Movie) { //does nothing } else { if (show.StatusId == GlobalConfig.Visible) { if (show.StartDate < registDt && show.EndDate > registDt) { JsonFeatureItem j = new JsonFeatureItem() { ShowId = show.CategoryId, ShowName = show.CategoryName, ShowDescription = show.Description, ShowImageUrl = GlobalConfig.ShowImgPath + show.CategoryId + "/" + show.ImagePoster }; jfi.Add(j); } } } } } } catch (Exception) { } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public JsonResult GetListing(int id) { List<JsonFeatureItem> jfi = null; var cache = DataCache.Cache; string cacheKey = "JRGL:O:" + id.ToString() + ";C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode(); jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); if (feature == null) return this.Json(string.Empty, JsonRequestBehavior.AllowGet); List<FeatureItem> featureItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.AuditTrail.UpdatedOn).ToList(); jfi = new List<JsonFeatureItem>(); foreach (EpisodeFeatureItem f in featureItems) { if (f is EpisodeFeatureItem) { Episode ep = context.Episodes.FirstOrDefault(e => e.EpisodeId == f.EpisodeId && e.OnlineStatusId == GlobalConfig.Visible); if (ep != null) { //var excludedCategoryIds = MyUtility.StringToIntList(GlobalConfig.ExcludedCategoryIdsForDisplay); //var epCategory = ep.EpisodeCategories.FirstOrDefault(e => !excludedCategoryIds.Contains(e.CategoryId)); string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); EpisodeCategory epCategory = null; if (GlobalConfig.UseServiceOfferingWhenCheckingEpisodeParentCategory) { var ShowListBasedOnCountryCode = ContextHelper.GetAllShowsBasedOnCountryCode(context, CountryCode, true); epCategory = ep.EpisodeCategories.FirstOrDefault(e => ShowListBasedOnCountryCode.Contains(e.CategoryId)); } else { var excludedCategoryIds = MyUtility.StringToIntList(GlobalConfig.ExcludedCategoryIdsForDisplay); epCategory = ep.EpisodeCategories.FirstOrDefault(e => !excludedCategoryIds.Contains(e.CategoryId)); } if (epCategory != null) { Show show = epCategory.Show; if (show != null) { string img = String.IsNullOrEmpty(ep.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, ep.EpisodeId.ToString(), ep.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); JsonFeatureItem j = new JsonFeatureItem() { EpisodeId = ep.EpisodeId, EpisodeDescription = MyUtility.Ellipsis(ep.Description, 20), EpisodeName = ep.EpisodeName, EpisodeAirDate = (ep.DateAired != null) ? ep.DateAired.Value.ToString("MMM d, yyyy") : "", ShowId = show.CategoryId, ShowName = String.Compare(ep.EpisodeName, ep.EpisodeCode) == 0 ? MyUtility.Ellipsis(show.CategoryName, 20) : MyUtility.Ellipsis(ep.EpisodeName, 20), EpisodeImageUrl = img, ShowImageUrl = showImg, Blurb = HttpUtility.HtmlEncode(MyUtility.Ellipsis(ep.Synopsis, 80)) }; jfi.Add(j); } } } } } cache.Put(cacheKey, jfi, DataCache.CacheDuration); } return this.Json(jfi, JsonRequestBehavior.AllowGet); }
public ActionResult GetFeatureTeamsPR() { List<JsonFeatureItem> jfi = null; var cache = DataCache.Cache; string cacheKey = "UAAPGFTPR:0;"; jfi = (List<JsonFeatureItem>)cache[cacheKey]; if (jfi == null) { var context = new IPTV2Entities(); var socialContext = new EngagementsEntities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == GlobalConfig.UAAPTeamsFeatureId && f.StatusId == GlobalConfig.Visible); if (feature != null) { var featureItems1 = feature.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible); if (featureItems1 != null) { List<FeatureItem> featureItems = featureItems1.OrderByDescending(f => f.AuditTrail.UpdatedOn).ToList(); jfi = new List<JsonFeatureItem>(); foreach (var f in featureItems) { if (f is CelebrityFeatureItem) { var celeb = (CelebrityFeatureItem)f; Celebrity person = celeb.Celebrity; string img = String.IsNullOrEmpty(person.ImageUrl) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, person.CelebrityId.ToString(), person.ImageUrl); var lovesCountSummary = socialContext.CelebrityReactionSummaries.FirstOrDefault(i => i.CelebrityId == celeb.CelebrityId && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE); int love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total); var commentsCountSummary = socialContext.CelebrityReactionSummaries.FirstOrDefault(i => i.CelebrityId == celeb.CelebrityId && i.ReactionTypeId == GlobalConfig.SOCIAL_COMMENT); int comment = (int)(commentsCountSummary == null ? 0 : commentsCountSummary.Total); JsonFeatureItem j = new JsonFeatureItem() { CelebrityFullName = person.FullName, ShowId = person.CelebrityId, ShowImageUrl = img, Blurb = person.Height.ToString(), EpisodeDescription = love.ToString() + "-" + comment.ToString() }; jfi.Add(j); } } cache.Put(cacheKey, jfi, DataCache.CacheDuration); } } } return PartialView(jfi); }