コード例 #1
0
        public ActionResult CelebrityReactions(Guid userId, int reactionTypeId, int celebrityId, string action)
        {
            var context = new EngagementsEntities();
            int returnValue = 0;

            var celebrity = context.CelebrityReactions.FirstOrDefault(c => c.CelebrityId == celebrityId && c.ReactionTypeId == reactionTypeId && c.UserId == userId);
            //var celebrity = context.CelebrityReactions.Where(c => c.CelebrityId == celebrityId && c.ReactionTypeId == reactionTypeId && c.UserId == userId).FirstOrDefault();
            if (celebrity == null)
            {
                if (!String.IsNullOrEmpty(action.ToString()) && action.ToString().Equals("add"))
                {
                    CelebrityReaction celebrityReaction = new CelebrityReaction();
                    celebrityReaction.UserId = userId;
                    celebrityReaction.CelebrityId = celebrityId;
                    celebrityReaction.ReactionTypeId = reactionTypeId;
                    celebrityReaction.DateTime = DateTime.Now;
                    context.CelebrityReactions.Add(celebrityReaction);

                    returnValue = context.SaveChanges();
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(action.ToString()) && action.ToString().Equals("remove"))
                {
                    context.CelebrityReactions.Remove(celebrity);
                    returnValue = context.SaveChanges();
                }
            }
            return Json(new { result = returnValue }, JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
        public ActionResult ShowReactions(Guid userId, int reactionTypeId, int categoryId, string action)
        {
            var context = new EngagementsEntities();
            int returnValue = 0;

            var show = context.ShowReactions.FirstOrDefault(s => s.CategoryId == categoryId && s.ReactionTypeId == reactionTypeId && s.UserId == userId);
            if (show == null)
            {
                if (!String.IsNullOrEmpty(action.ToString()) && action.ToString().Equals("add"))
                {
                    ShowReaction showReaction = new ShowReaction();
                    showReaction.UserId = userId;
                    showReaction.CategoryId = categoryId;
                    showReaction.ReactionTypeId = reactionTypeId;
                    showReaction.DateTime = DateTime.Now;
                    context.ShowReactions.Add(showReaction);

                    returnValue = context.SaveChanges();
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(action.ToString()) && action.ToString().Equals("remove"))
                {
                    context.ShowReactions.Remove(show);
                    returnValue = context.SaveChanges();
                }
            }
            return Json(new { result = returnValue }, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
        public ActionResult ContenderDetails(int? id)
        {
            if (id != null)
            {
                var context = new IPTV2Entities();
                var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == id);
                var socialContext = new EngagementsEntities();
                if (celebrity != null)
                {
                    if (String.IsNullOrEmpty(celebrity.Description))
                        celebrity.Description = "No description yet.";

                    if (String.IsNullOrEmpty(celebrity.ImageUrl))
                        celebrity.ImageUrl = String.Format("{0}/{1}", GlobalConfig.AssetsBaseUrl, "content/images/celebrity/unknown.jpg");
                    else
                        celebrity.ImageUrl = String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, celebrity.CelebrityId, celebrity.ImageUrl);

                    if (MyUtility.isUserLoggedIn() && ContextHelper.HasSocialEngagement(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_LOVE, (int)id, EngagementContentType.Celebrity))
                        ViewBag.Loved = true;
                    var lovesCountSummary = socialContext.CelebrityReactionSummaries.FirstOrDefault(i => i.CelebrityId == celebrity.CelebrityId && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE);
                    int love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total);
                    celebrity.Weight = love.ToString();
                    if (!String.IsNullOrEmpty(celebrity.Birthday))
                        ViewBag.BirthDate = celebrity.Birthday;
                    if (!String.IsNullOrEmpty(celebrity.Birthplace))
                    {
                        ViewBag.BirthPlace = celebrity.Birthplace;
                        celebrity.Birthplace = "<p>" + celebrity.FirstName + " VS " + celebrity.Birthplace.Replace(",", "</p><p>" + celebrity.FirstName + " VS ") + "</p>";
                        celebrity.Birthplace = celebrity.Birthplace.Replace(":", "<br />");
                    }
                    return View(celebrity);
                }
            }
            return RedirectToAction("Index", "Home");
        }
コード例 #4
0
        public bool HasSocialEngagementRecordOnCelebrity(Guid userId, int reactionTypeId, int celebrityId)
        {
            var context = new EngagementsEntities();

            var celebrity = context.CelebrityReactions.FirstOrDefault(c => c.CelebrityId == celebrityId && c.ReactionTypeId == reactionTypeId && c.UserId == userId);

            if (celebrity == null)
                return false;

            return true;
        }
コード例 #5
0
        public ActionResult Finalists(int? id)
        {
            try
            {
                List<Celebrity> jfi = null;
                var socialContext = new EngagementsEntities();
                var context = new IPTV2Entities();
                var feature = context.Features.FirstOrDefault(f => f.FeatureId == GlobalConfig.EventCelebritiesFeatureID && f.StatusId == GlobalConfig.Visible);

                List<FeatureItem> featureItems = feature.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible).ToList();
                List<int> idlist = new List<int>();
                foreach (var f in featureItems)
                {
                    if (f is CelebrityFeatureItem)
                    {
                        var cft = (CelebrityFeatureItem)f;
                        idlist.Add(cft.CelebrityId);
                    }
                }
                var celeb = context.Celebrities.Where(c => idlist.Contains(c.CelebrityId));
                jfi = new List<Celebrity>();
                foreach (Celebrity person in celeb)
                {
                    bool hasLoved = MyUtility.isUserLoggedIn() && ContextHelper.HasSocialEngagement(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_LOVE, (int)person.CelebrityId, EngagementContentType.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);
                    var commentsCountSummary = socialContext.CelebrityReactionSummaries.FirstOrDefault(i => i.CelebrityId == person.CelebrityId && i.ReactionTypeId == GlobalConfig.SOCIAL_COMMENT);
                    int comment = (int)(commentsCountSummary == null ? 0 : commentsCountSummary.Total);
                    person.ImageUrl = img;
                    person.Birthday = love.ToString() + "-" + comment.ToString();
                    Celebrity c = new Celebrity() { CelebrityId = person.CelebrityId, ImageUrl = person.ImageUrl, FullName = person.FullName, Birthday = person.Birthday, ZodiacSign = person.ZodiacSign, ChineseYear = person.ChineseYear, Birthplace = hasLoved.ToString() };
                    jfi.Add(c);
                }
                return View(jfi);
            }
            catch (Exception) { throw; }
        }
コード例 #6
0
        public JsonResult GetMostLovedShows()
        {
            try
            {
                var socialContext = new EngagementsEntities();
                var context = new IPTV2Entities();

                var mostLovedShowReactions = socialContext.ShowReactions
                    .Where(c => c.ReactionTypeId == 12)
                    .GroupBy(c => c.CategoryId)
                    .Select(c => new
                    {
                        CategoryId = c.Key,
                        TotalLoved = c.Count()
                    }).ToList().OrderByDescending(c => c.TotalLoved).Take(5);

                var mostLovedShows = mostLovedShowReactions.Join(
                        context.CategoryClasses,
                        sr => sr.CategoryId,
                        cc => cc.CategoryId,
                        (sr, cc) => new { ShowReaction = sr, CategoryClasses = cc })
                        .Select(show => new
                        {
                            categoryName = show.CategoryClasses.CategoryName,
                            categoryId = show.CategoryClasses.CategoryId,
                            totalLove = show.ShowReaction.TotalLoved,
                            image = String.IsNullOrEmpty(show.CategoryClasses.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryClasses.CategoryId.ToString(), show.CategoryClasses.ImagePoster),
                            blurb = show.CategoryClasses.Blurb
                        });

                if (mostLovedShows != null)
                    return Json(mostLovedShows, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return null;
        }
コード例 #7
0
        public JsonResult GetMostLovedEpisodes()
        {
            try
            {
                var socialContext = new EngagementsEntities();
                var context = new IPTV2Entities();

                var mostLovedEpisodeReactions = socialContext.EpisodeReactions
                    .Where(rtId => rtId.ReactionTypeId == 12)
                    .GroupBy(e => e.EpisodeId)
                    .Select(e => new
                    {
                        EpisodeId = e.Key,
                        TotalLoved = e.Count()
                    }).ToList().OrderByDescending(e => e.TotalLoved).Take(5);

                var mostLovedEpisodes = mostLovedEpisodeReactions.Join(
                        context.Episodes,
                        er => er.EpisodeId,
                        ee => ee.EpisodeId,
                        (er, ee) => new { EpisodeReactions = er, Episodes = ee })
                        .Select(episode => new
                        {
                            showId = episode.Episodes.EpisodeCategories.FirstOrDefault().Show.CategoryId,
                            showName = episode.Episodes.EpisodeCategories.FirstOrDefault().Show.Description,
                            dateAired = episode.Episodes.DateAired.Value.ToString("MMM d, yyyy"),
                            episodeName = episode.Episodes.Description,
                            episodeId = episode.Episodes.EpisodeId,
                            totalLove = episode.EpisodeReactions.TotalLoved,
                            image = String.IsNullOrEmpty(episode.Episodes.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, episode.Episodes.EpisodeId.ToString(), episode.Episodes.ImageAssets.ImageVideo),
                            blurb = episode.Episodes.Synopsis
                        });

                if (mostLovedEpisodes != null)
                    return Json(mostLovedEpisodes, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return null;
        }
コード例 #8
0
        public ActionResult GetUserLovedCelebrities(Guid id)
        {
            var socialContext = new EngagementsEntities();
            var context = new IPTV2Entities();

            var userLovedCelebrities = socialContext.CelebrityReactions
                .Where(show => show.UserId == id && show.ReactionTypeId == GlobalConfig.SOCIAL_LOVE)
                .Select(show => new
                {
                    celebrityId = show.CelebrityId
                }).Distinct().ToList();

            var lovedCelebrities = userLovedCelebrities.Join(
                    context.Celebrities,
                    cr => cr.celebrityId,
                    celeb => celeb.CelebrityId,
                    (cr, celeb) => new { CelebrityReaction = cr, Celebrities = celeb })
                    .Select(celebrity => new
                    {
                        CelebrityFullName = celebrity.Celebrities.FullName,
                        ShowId = celebrity.Celebrities.CelebrityId,
                        ShowImageUrl = GlobalConfig.CelebrityImgPath + celebrity.Celebrities.CelebrityId + "/" + celebrity.Celebrities.ImageUrl,
                    });

            if (lovedCelebrities != null)
                return Json(lovedCelebrities, JsonRequestBehavior.AllowGet);

            return null;
        }
コード例 #9
0
        ////[OutputCache(VaryByParam = "id", Duration = 300)]
        //public ActionResult DetailsBAK(int? id, string slug)
        //{
        //    var profiler = MiniProfiler.Current;

        //    if (id != null)
        //    {
        //        CategoryClass category = null;
        //        //var cache = DataCache.Cache;
        //        //string cacheKey = "SCCD:O:" + id.ToString() + ";C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode();
        //        //category = (CategoryClass)cache[cacheKey];

        //        if (id == GlobalConfig.TFCkatCategoryId)
        //            return Redirect("/TFCkat");

        //        if (id == GlobalConfig.UAAPGreatnessNeverEndsCategoryId)
        //            return RedirectToAction("Index", "UAAP");
        //        var excludedCategoryIds = MyUtility.StringToIntList(GlobalConfig.ExcludedCategoryIdsForDisplay);
        //        if (excludedCategoryIds.Contains((int)id))
        //            return RedirectToAction("Index", "Home");

        //        var context = new IPTV2Entities();
        //        //if (category == null)
        //        //{
        //        category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id && c.StatusId == GlobalConfig.Visible);
        //        //  cache.Put(cacheKey, category, DataCache.CacheDuration);
        //        //}

        //        //var  offering = context.Offerings.Find(GlobalConfig.offeringId);                
        //        //var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
        //        //var showIds = service.GetAllOnlineShowIds(MyUtility.GetCurrentCountryCodeOrDefault());
        //        //if(!showIds.Contains((int)id))

        //        if (category != null && category is Show)
        //        {
        //            var dbSlug = MyUtility.GetSlug(category.Description);
        //            if (String.Compare(dbSlug, slug, false) != 0)
        //                return RedirectToActionPermanent("Details", new { id = id, slug = dbSlug });

        //            var show = (Show)category;

        //            if (!ContextHelper.IsCategoryViewableInUserCountry(show))
        //                return RedirectToAction("Index", "Home");

        //            ViewBag.Loved = false;

        //            DateTime registDt = DateTime.Now;
        //            if (show.StartDate > registDt)
        //                return RedirectToAction("Index", "Home");
        //            if (show.EndDate < registDt)
        //                return RedirectToAction("Index", "Home");

        //            //var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId);
        //            //var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
        //            //SortedSet<int> showIds = service.GetAllOnlineShowIds(MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode());

        //            //if (!showIds.Contains(show.CategoryId))
        //            //    return RedirectToAction("Index", "Home");
        //            using (profiler.Step("Episode Count"))
        //            {
        //                ViewBag.ShowId = show.CategoryId;
        //                //ViewBag.EpisodeCount = show.Episodes.Where(e => e.Episode.OnlineStatusId == GlobalConfig.Visible).Count();
        //                ViewBag.EpisodeCount = context.EpisodeCategories1.Count(e => e.Episode.OnlineStatusId == GlobalConfig.Visible && e.Show.CategoryId == show.CategoryId);
        //            }



        //            //if (MyUtility.isUserLoggedIn())
        //            //{
        //            //    System.Guid userId = new System.Guid(User.Identity.Name);
        //            //    User user = context.Users.FirstOrDefault(u => u.UserId == userId);
        //            //    if (user != null)
        //            //        ViewBag.EmailAddress = user.EMail;
        //            //}


        //            /**** Check for Free Trial ****/
        //            bool showFreeTrialImage = false;
        //            using (profiler.Step("Check for Early Bird"))
        //            {
        //                if (GlobalConfig.IsEarlyBirdEnabled)
        //                {
        //                    if (MyUtility.isUserLoggedIn())
        //                    {

        //                        var user = context.Users.FirstOrDefault(u => u.UserId == new Guid(User.Identity.Name));
        //                        if (user != null)
        //                        {
        //                            ViewBag.EmailAddress = user.EMail;
        //                            var offering = context.Offerings.Find(GlobalConfig.offeringId);
        //                            if (user.IsFirstTimeSubscriber(offering, true, MyUtility.StringToIntList(GlobalConfig.FreeTrialPackageIds), context))
        //                                showFreeTrialImage = true;
        //                        }
        //                        //showFreeTrialImage = true;
        //                    }
        //                }

        //            }

        //            //REMOVE THIS LINE ON RELEASE OF EARLY BIRD.
        //            //showFreeTrialImage = false;
        //            ViewBag.ShowFreeTrialImage = showFreeTrialImage;


        //            bool isUserEntitled = false;
        //            if (MyUtility.isUserLoggedIn())
        //            {
        //                System.Guid userId = new System.Guid(User.Identity.Name);
        //                User user = context.Users.FirstOrDefault(u => u.UserId == userId);
        //                if (user != null)
        //                    ViewBag.EmailAddress = user.EMail;
        //            }

        //            using (profiler.Step("Social Love"))
        //            {
        //                if (MyUtility.isUserLoggedIn() && HasSocialEngagementRecordOnShow(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_LOVE, (int)id))
        //                    ViewBag.Loved = true;
        //            }

        //            using (profiler.Step("Social Rating"))
        //            {
        //                if (MyUtility.isUserLoggedIn() && HasSocialEngagementRecordOnShow(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_RATING, (int)id))
        //                    ViewBag.Rated = true;
        //            }


        //            //CHECK USER IF CAN PLAY VIDEO
        //            using (profiler.Step("Check If User Is Entitled"))
        //            {
        //                try
        //                {
        //                    var offering = context.Offerings.Find(GlobalConfig.offeringId);
        //                    var ec = context.EpisodeCategories1.FirstOrDefault(c => c.CategoryId == id);
        //                    if (ec != null)
        //                    {
        //                        var episode = ec.Episode;
        //                        var premiumAsset = episode.PremiumAssets.FirstOrDefault();
        //                        if (premiumAsset != null)
        //                        {
        //                            var asset = premiumAsset.Asset;
        //                            //isUserEntitled = user.IsEpisodeEntitled(offering, episode, asset, RightsType.Online);
        //                            //isUserEntitled = user.CanPlayVideo(offering, episode, asset, RightsType.Online);
        //                            isUserEntitled = ContextHelper.CanPlayVideo(context, offering, episode, asset, User, Request);
        //                        }
        //                    }
        //                }
        //                catch (Exception) { }
        //            }

        //            ViewBag.IsUserEntitled = isUserEntitled;


        //            ViewBag.ShowPackageProductPrices = null;
        //            string countryCode = MyUtility.GetCurrentCountryCodeOrDefault();
        //            ViewBag.CountryCode = countryCode;
        //            if (!isUserEntitled)
        //            {
        //                using (profiler.Step("Get Show Package & Product Prices"))
        //                {
        //                    try
        //                    {
        //                        ViewBag.ShowPackageProductPrices = ContextHelper.GetShowPackageProductPrices(show.CategoryId, countryCode);
        //                    }
        //                    catch (Exception e) { MyUtility.LogException(e); }
        //                }
        //            }

        //            using (profiler.Step("Checking if its a movie/special"))
        //            {
        //                if (show is Movie)
        //                {
        //                    ViewBag.HideEpisodeList = true;
        //                    ViewBag.CategoryType = "Movie";
        //                    //redirect to MovieVideo View
        //                    return View("MovieVideo", show);
        //                }
        //                else if (show is SpecialShow)
        //                {
        //                    ViewBag.HideEpisodeList = true;
        //                    ViewBag.CategoryType = "Special";

        //                    //redirect to MovieVideo View
        //                    return View("MovieVideo", show);
        //                }
        //                else if (show is LiveEvent)
        //                {
        //                    // transfer user to LiveEvent page format
        //                    ViewBag.HideEpisodeList = true;
        //                    ViewBag.CategoryType = "LiveEvent";

        //                    var episode = show.Episodes.FirstOrDefault(e => e.Episode.OnlineStatusId == GlobalConfig.Visible);
        //                    if (episode != null)
        //                        return RedirectToAction("Details", "Live", new { id = episode.EpisodeId, slug = dbSlug });

        //                    //return View("LiveEvent", show);
        //                }
        //                //foreach (var item in show.ParentCategories.ToList())
        //                //{
        //                //    ViewBag.HideEpisodeList = true;
        //                //    string categories = item.Description + ", ";
        //                //    ViewBag.Category = categories.Trim().TrimEnd(',');

        //                //    if (item.CategoryClassParentCategories.Where(p => p.ParentId == GlobalConfig.Movies).Count() > 0)
        //                //    {
        //                //        ViewBag.CategoryType = "Movie";
        //                //        if (MyUtility.isUserLoggedIn())
        //                //        {
        //                //            System.Guid userId = new System.Guid(User.Identity.Name);
        //                //            User user = context.Users.FirstOrDefault(u => u.UserId == userId);
        //                //            if (user != null)
        //                //                ViewBag.EmailAddress = user.EMail;
        //                //        }
        //                //        //redirect to MovieVideo View
        //                //        return View("MovieVideo", show);
        //                //    }
        //                //}
        //            }

        //            return View(show);
        //        }
        //    }
        //    return RedirectToAction("Index", "Home");
        //}

        private bool HasSocialEngagementRecordOnShow(Guid userId, int reactionTypeId, int categoryId)
        {
            var context = new EngagementsEntities();

            var show = context.ShowReactions.FirstOrDefault(s => s.CategoryId == categoryId && s.ReactionTypeId == reactionTypeId && s.UserId == userId);

            if (show == null)
                return false;

            return true;
        }
コード例 #10
0
        public void FillTopReviewersCache1(IPTV2Entities context, EngagementsEntities socialContext, int offeringId, int serviceId, TimeSpan cacheDuration, int SOCIAL_RATING, string AssetsBaseUrl)
        {
            List<TopReviewersDisplay> topReviewers = null;
            try
            {
                try
                {
                    string cacheKey = "SEGTR1:O;C:";
                    topReviewers = new List<TopReviewersDisplay>();

                    var topReviewersAll = socialContext.EpisodeReactions
                        .Where(rtId => rtId.ReactionTypeId == SOCIAL_RATING)
                        .Select(user => new { user.UserId, user.Reactionid })
                        .Union(socialContext.ShowReactions.Where(rtId => rtId.ReactionTypeId == SOCIAL_RATING)
                        .Select(user => new { user.UserId, user.Reactionid })).GroupBy(user => user.UserId)
                        .Select(user => new
                        {
                            userId = user.Key,
                            totalReview = user.Count()
                        }).ToList().OrderByDescending(user => user.totalReview).Take(5);

                    try
                    {
                        foreach (var item in topReviewersAll)
                        {
                            var user = context.Users.FirstOrDefault(u => u.UserId == item.userId);
                            if (user != null)
                            {
                                try
                                {
                                    topReviewers.Add(new TopReviewersDisplay()
                                    {
                                        userId = item.userId.ToString(),
                                        userName = String.Format("{0} {1}", user.FirstName, user.LastName),
                                        userPhoto = GetUserImage(item.userId, AssetsBaseUrl),
                                        totalReview = item.totalReview
                                    });
                                }
                                catch (Exception e) { Trace.Fail(e.Message); }
                            }
                        }
                        var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(topReviewers);
                        DataCache.Cache.Put(cacheKey, jsonString, cacheDuration);
                    }
                    catch (Exception e) { Trace.Fail(e.Message); }
                }
                catch (Exception e) { Trace.Fail(e.Message); }

            }
            catch (Exception e) { Trace.Fail(e.Message); }
        }
コード例 #11
0
        //

        // GET: /Episode/

        //public ActionResult Index()
        //{
        //    return View();
        //}

        //

        // GET: /Episode/Details/5

        //public ActionResult DetailsBAK(int? id, string slug)
        //{
        //    if (id != null)
        //    {
        //        var profiler = MiniProfiler.Current;
        //        var context = new IPTV2Entities();

        //        Episode episode = context.Episodes.FirstOrDefault(e => e.EpisodeId == id);
        //        if (episode == null)
        //            return RedirectToAction("Index", "Home");

        //        DateTime registDt = DateTime.Now;
        //        if (episode.OnlineStartDate > registDt)
        //            return RedirectToAction("Index", "Home");
        //        if (episode.OnlineEndDate < registDt)
        //            return RedirectToAction("Index", "Home");

        //        bool isUserEntitled = false;
        //        var dbSlug = MyUtility.GetSlug(episode.Description);
        //        if (episode.IsLiveChannelActive == true)
        //            return RedirectToActionPermanent("Details", "Live", new { id = id, slug = dbSlug });

        //        //var parentCategories = episode.EpisodeCategories.Where(e => e.Episode.OnlineStatusId == GlobalConfig.Visible).Select(e => e.CategoryId);
        //        var parentCategories = episode.GetParentShows();
        //        if (parentCategories.Count() > 0)
        //        {
        //            if (parentCategories.Contains(GlobalConfig.HalalanNewsAlertsParentCategoryId))
        //                return RedirectToActionPermanent("NewsAlerts", "Halalan2013", new { id = id, slug = dbSlug });
        //            else if (parentCategories.Contains(GlobalConfig.HalalanAdvisoriesParentCategoryId))
        //                return RedirectToActionPermanent("Advisories", "Halalan2013", new { id = id, slug = dbSlug });
        //            else if (parentCategories.Contains(GlobalConfig.TFCkatCategoryId))
        //                return RedirectToActionPermanent("OnDemand", "TFCkat", new { id = id, slug = dbSlug });
        //            else if (parentCategories.Contains(GlobalConfig.UAAPGreatnessNeverEndsCategoryId))
        //                return RedirectToActionPermanent("OnDemand", "UAAP", new { id = id, slug = dbSlug });
        //        }

        //        var excludedCategoryIds = MyUtility.StringToIntList(GlobalConfig.ExcludedCategoryIdsForDisplay);
        //        EpisodeCategory category = episode.EpisodeCategories.FirstOrDefault(e => e.Episode.OnlineStatusId == GlobalConfig.Visible && !excludedCategoryIds.Contains(e.CategoryId));

        //        if (category != null)
        //        {

        //            ViewBag.Show = category.Show;

        //            if (!ContextHelper.IsCategoryViewableInUserCountry(category.Show))
        //                return RedirectToAction("Index", "Home");

        //            var tempShowNameWithDate = String.Format("{0} {1}", category.Show.Description, episode.DateAired.Value.ToString("MMM dd, yyyy"));
        //            dbSlug = MyUtility.GetSlug(tempShowNameWithDate);
        //            if (String.Compare(dbSlug, slug, false) != 0)
        //                return RedirectToActionPermanent("Details", new { id = id, slug = dbSlug });

        //            //if (category.CategoryId == GlobalConfig.TFCkatCategoryId)
        //            //    return Redirect(String.Format("/TFCkat/{0}", id));

        //            if (MyUtility.isUserLoggedIn())
        //            {
        //                System.Guid userId = new System.Guid(User.Identity.Name);
        //                User user = context.Users.FirstOrDefault(u => u.UserId == userId);
        //                if (user != null)
        //                    ViewBag.EmailAddress = user.EMail;
        //            }

        //            //CHECK USER IF CAN PLAY VIDEO
        //            using (profiler.Step("Check if User is Entitled"))
        //            {
        //                try
        //                {
        //                    var offering = context.Offerings.Find(GlobalConfig.offeringId);
        //                    var premiumAsset = episode.PremiumAssets.FirstOrDefault();
        //                    if (premiumAsset != null)
        //                    {
        //                        var assetTemp = premiumAsset.Asset;
        //                        //isUserEntitled = user.IsEpisodeEntitled(offering, episode, asset, RightsType.Online);
        //                        //isUserEntitled = user.CanPlayVideo(offering, episode, asset, RightsType.Online);
        //                        isUserEntitled = ContextHelper.CanPlayVideo(context, offering, episode, assetTemp, User, Request);
        //                    }
        //                }
        //                catch (Exception) { }
        //            }

        //            ViewBag.IsUserEntitled = isUserEntitled;

        //            //context.EpisodeCategories1.Count(s => s.CategoryId == category.CategoryId && s.Episode.OnlineStatusId == GlobalConfig.Visible);
        //            //var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId);
        //            //var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
        //            //SortedSet<int> showIds = service.GetAllOnlineShowIds(MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode());

        //            //if (!showIds.Contains(category.Show.CategoryId))
        //            //    return RedirectToAction("Index", "Home");

        //            ViewBag.CategoryType = "Show";
        //            if (category.Show is Movie)
        //                ViewBag.CategoryType = "Movie";
        //            else if (category.Show is SpecialShow)
        //                ViewBag.CategoryType = "SpecialShow";
        //            else if (category.Show is WeeklyShow)
        //                ViewBag.CategoryType = "WeeklyShow";
        //            else if (category.Show is DailyShow)
        //                ViewBag.CategoryType = "DailyShow";

        //            //IOrderedEnumerable<EpisodeCategory> episodes = null;
        //            //IOrderedQueryable<EpisodeCategory> episodes = null;
        //            IOrderedQueryable<Episode> episodes = null;

        //            var episode_list = context.EpisodeCategories1.Where(s => s.CategoryId == category.CategoryId && s.Episode.OnlineStatusId == GlobalConfig.Visible).Select(e => e.EpisodeId);
        //            using (profiler.Step("Get Episodes"))
        //            {
        //                //episodes = category.Show.Episodes.Where(e => e.Episode.OnlineStatusId == GlobalConfig.Visible).OrderBy(e => e.Episode.DateAired);
        //                episodes = context.Episodes.Where(e => episode_list.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible && e.OnlineStartDate < registDt && e.OnlineEndDate > registDt).OrderBy(e => e.DateAired);
        //            }
        //            var eplist = episodes.ToList();
        //            ViewBag.EpisodeNumber = eplist.IndexOf(episode) + 1;

        //            //var GetNext = eplist.FirstOrDefault(e => e.Episode.EpisodeNumber > episode.EpisodeNumber);

        //            var GetNextEpisodeId = eplist.FirstOrDefault(e => e.DateAired > episode.DateAired);
        //            if (GetNextEpisodeId != null)
        //            {
        //                var GetNext = context.EpisodeCategories1.FirstOrDefault(e => e.EpisodeId == GetNextEpisodeId.EpisodeId);
        //                ViewBag.GetNext = GetNext != null ? GetNext : category;
        //            }
        //            else
        //                ViewBag.GetNext = category;

        //            //var GetPrevious = eplist.LastOrDefault(e => e.Episode.EpisodeNumber < episode.EpisodeNumber);

        //            var GetPreviousEpisodeId = eplist.LastOrDefault(e => e.DateAired < episode.DateAired);
        //            if (GetPreviousEpisodeId != null)
        //            {
        //                var GetPrevious = context.EpisodeCategories1.FirstOrDefault(e => e.EpisodeId == GetPreviousEpisodeId.EpisodeId);
        //                ViewBag.GetPrevious = GetPrevious != null ? GetPrevious : category;
        //            }
        //            else
        //                ViewBag.GetPrevious = category;

        //            ViewBag.EpisodeCount = episodes.Count();

        //            ViewBag.ShowId = category.Show.CategoryId;

        //            int episodeId = episode.EpisodeId;

        //            ViewBag.EpisodeId = episodeId;

        //            Asset asset = episode.PremiumAssets.FirstOrDefault().Asset;

        //            int assetId = asset == null ? 0 : asset.AssetId;

        //            ViewBag.AssetId = assetId;

        //            //ViewBag.VideoUrl = Helpers.Akamai.GetVideoUrl(episodeId, assetId, Request, User);
        //            using (profiler.Step("Has Social Love"))
        //            {
        //                if (MyUtility.isUserLoggedIn() && HasSocialEngagementRecordOnEpisode(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_LOVE, (int)id))

        //                    ViewBag.Loved = true;
        //            }
        //            using (profiler.Step("Has Social Rating"))
        //            {
        //                if (MyUtility.isUserLoggedIn() && HasSocialEngagementRecordOnEpisode(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_RATING, (int)id))

        //                    ViewBag.Rated = true;
        //            }


        //            /**** Check for Free Trial ****/
        //            bool showFreeTrialImage = false;
        //            using (profiler.Step("Check for Early Bird"))
        //            {
        //                if (GlobalConfig.IsEarlyBirdEnabled)
        //                {
        //                    if (MyUtility.isUserLoggedIn())
        //                    {

        //                        var user = context.Users.FirstOrDefault(u => u.UserId == new Guid(User.Identity.Name));
        //                        if (user != null)
        //                        {
        //                            var offering = context.Offerings.Find(GlobalConfig.offeringId);
        //                            if (user.IsFirstTimeSubscriber(offering, true, MyUtility.StringToIntList(GlobalConfig.FreeTrialPackageIds), context))
        //                                showFreeTrialImage = true;
        //                        }
        //                        //showFreeTrialImage = true;
        //                    }
        //                }
        //            }
        //            //REMOVE THIS LINE ON RELEASE OF EARLY BIRD.
        //            //showFreeTrialImage = false;
        //            ViewBag.ShowFreeTrialImage = showFreeTrialImage;

        //            ViewBag.ShowPackageProductPrices = null;
        //            string countryCode = MyUtility.GetCurrentCountryCodeOrDefault();
        //            ViewBag.CountryCode = countryCode;
        //            if (!isUserEntitled)
        //            {
        //                using (profiler.Step("Get Show Package & Product Prices"))
        //                {
        //                    try
        //                    {
        //                        ViewBag.ShowPackageProductPrices = ContextHelper.GetShowPackageProductPrices(category.Show.CategoryId, countryCode);
        //                    }
        //                    catch (Exception e) { MyUtility.LogException(e); }
        //                }

        //            }
        //            return View(episode);
        //        }

        //        else
        //        {
        //            return RedirectToAction("Index", "Home");
        //        }
        //    }

        //    else return RedirectToAction("Index", "Home");
        //}

        private bool HasSocialEngagementRecordOnEpisode(Guid userId, int reactionTypeId, int episodeId)
        {
            var context = new EngagementsEntities();

            var episode = context.EpisodeReactions.FirstOrDefault(s => s.EpisodeId == episodeId && s.ReactionTypeId == reactionTypeId && s.UserId == userId);

            if (episode == null)

                return false;

            return true;
        }
コード例 #12
0
        public PartialViewResult GetReviewers()
        {
            List<TopReviewersDisplay> topReviewers = null;
            string jsonString = String.Empty;
            var cache = DataCache.Cache;
            string cacheKey = "SEGTR1:O;C:";
            try { jsonString = (string)cache[cacheKey]; }
            catch (Exception) { }
            try
            {
                if (String.IsNullOrEmpty(jsonString))
                {
                    topReviewers = new List<TopReviewersDisplay>();
                    var socialContext = new EngagementsEntities();
                    var context = new IPTV2Entities();
                    var topReviewersAll = socialContext.EpisodeReactions
                        .Where(rtId => rtId.ReactionTypeId == GlobalConfig.SOCIAL_RATING)
                        .Select(user => new { user.UserId, user.Reactionid })
                        .Union(socialContext.ShowReactions.Where(rtId => rtId.ReactionTypeId == GlobalConfig.SOCIAL_RATING)
                        .Select(user => new { user.UserId, user.Reactionid })).GroupBy(user => user.UserId)
                        .Select(user => new
                        {
                            userId = user.Key,
                            totalReview = user.Count()
                        }).OrderByDescending(user => user.totalReview).Take(5);

                    try
                    {
                        foreach (var item in topReviewersAll)
                        {
                            var user = context.Users.FirstOrDefault(u => u.UserId == item.userId);
                            if (user != null)
                            {
                                topReviewers.Add(new TopReviewersDisplay()
                                {
                                    userId = item.userId.ToString(),
                                    userName = String.Format("{0} {1}", user.FirstName, user.LastName),
                                    userPhoto = GetUserImage(item.userId),
                                    totalReview = item.totalReview
                                });
                            }
                        }
                        var cacheDuration = new TimeSpan(4, 0, 0);
                        jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(topReviewers);
                        cache.Put(cacheKey, jsonString, cacheDuration);
                    }
                    catch (Exception) { }
                }
                else
                    topReviewers = Newtonsoft.Json.JsonConvert.DeserializeObject<List<TopReviewersDisplay>>(jsonString);
            }
            catch (Exception e)
            {
                MyUtility.LogException(e);
            }
            return PartialView(topReviewers);
        }
コード例 #13
0
        public void FillMostLovedCelebrityCache(IPTV2Entities context, EngagementsEntities socialContext, int offeringId, int serviceId, TimeSpan cacheDuration, int SOCIAL_LOVE)
        {
            List<MostLovedCelebritiesDisplay> mostLovedCelebrities = null;
            try
            {
                var countries = context.Countries.ToList();
                foreach (var country in countries)
                {
                    try
                    {
                        string cacheKey = "SEGMLC1:O;C:" + country.Code;
                        mostLovedCelebrities = new List<MostLovedCelebritiesDisplay>();

                        //var mostLovedCelebrityReactions = socialContext.CelebrityReactions
                        //    .Where(rtId => rtId.ReactionTypeId == SOCIAL_LOVE)
                        //    .GroupBy(celeb => celeb.CelebrityId)
                        //    .Select(celeb => new
                        //    {
                        //        celebrityId = celeb.Key,
                        //        totalLoved = celeb.Count()
                        //    }).ToList().OrderByDescending(celeb => celeb.totalLoved).Take(5);
                        var mostLovedCelebrityReactions = socialContext.CelebrityReactionSummaries
                            .Where(rtId => rtId.ReactionTypeId == SOCIAL_LOVE)
                            .Select(celeb => new
                            {
                                celebrityId = celeb.CelebrityId,
                                totalLoved = celeb.Total7Days
                            }).ToList().OrderByDescending(celeb => celeb.totalLoved).Take(20);

                        try
                        {
                            int count = 0;
                            foreach (var item in mostLovedCelebrityReactions)
                            {

                                var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == item.celebrityId && c.StatusId == 1);
                                if (celebrity != null)
                                {
                                    try
                                    {
                                        mostLovedCelebrities.Add(new MostLovedCelebritiesDisplay()
                                        {
                                            celebrityId = item.celebrityId,
                                            celebrityName = celebrity.FullName,
                                            totalLove = item.totalLoved
                                        });
                                        count++;
                                    }
                                    catch (Exception e) { Trace.Fail(e.Message); }

                                }
                                if (count > 4)
                                    break;
                            }
                            DataCache.Cache.Put(cacheKey, mostLovedCelebrities, cacheDuration);
                        }
                        catch (Exception e) { Trace.Fail(e.Message); }
                    }
                    catch (Exception e) { Trace.Fail(e.Message); }
                }
            }
            catch (Exception) { }
        }
コード例 #14
0
        public ActionResult EpisodeReactions(Guid userId, int reactionTypeId, int episodeId, string action)
        {
            var context = new EngagementsEntities();
            int returnValue = 0;

            var episode = context.EpisodeReactions.FirstOrDefault(e => e.EpisodeId == episodeId && e.ReactionTypeId == reactionTypeId && e.UserId == userId);
            if (episode == null)
            {
                if (!String.IsNullOrEmpty(action.ToString()) && action.ToString().Equals("add"))
                {
                    EpisodeReaction episodeReaction = new EpisodeReaction();
                    episodeReaction.UserId = userId;
                    episodeReaction.EpisodeId = episodeId;
                    episodeReaction.ReactionTypeId = reactionTypeId;
                    episodeReaction.DateTime = DateTime.Now;
                    context.EpisodeReactions.Add(episodeReaction);

                    returnValue = context.SaveChanges();
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(action.ToString()) && action.ToString().Equals("remove"))
                {
                    context.EpisodeReactions.Remove(episode);
                    returnValue = context.SaveChanges();
                }
            }
            return Json(new { result = returnValue }, JsonRequestBehavior.AllowGet);
        }
コード例 #15
0
        public ActionResult GetLovedCount(int? ID, string type)
        {
            int love = 0;
            var socialContext = new EngagementsEntities();
            switch (type)
            {
                case "show":
                    {
                        var lovesCountSummary = socialContext.ShowReactionSummaries.FirstOrDefault(i => i.CategoryId == ID && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE);
                        love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total);
                        break;
                    }
                case "celebrity":
                    {
                        var lovesCountSummary = socialContext.CelebrityReactionSummaries.FirstOrDefault(i => i.CelebrityId == ID && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE);
                        love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total);
                        break;
                    }
                case "episode":
                    {
                        var lovesCountSummary = socialContext.EpisodeReactionSummaries.FirstOrDefault(i => i.EpisodeId == ID && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE);
                        love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total);
                        break;
                    }
                case "channel":
                    {
                        var lovesCountSummary = socialContext.ChannelReactionSummaries.FirstOrDefault(i => i.ChannelId == ID && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE);
                        love = (int)(lovesCountSummary == null ? 0 : lovesCountSummary.Total);
                        break;
                    }

            }

            return Json(love, JsonRequestBehavior.AllowGet);
        }
コード例 #16
0
 public ActionResult UpdateReaction(Guid userId, int reactionTypeId, string idx, string action, string type)
 {
     int returnValue = 0;
     try
     {
         if (!String.IsNullOrEmpty(type))
         {
             var context = new EngagementsEntities();
             DateTime registDt = DateTime.Now;
             switch (type)
             {
                 case "show":
                     {
                         var showId = Convert.ToInt32(idx);
                         var show = context.ShowReactions.FirstOrDefault(i => i.CategoryId == showId && i.ReactionTypeId == reactionTypeId && i.UserId == userId);
                         if (show == null)
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "add", true) == 0)
                             {
                                 var reaction = new ShowReaction()
                                 {
                                     UserId = userId,
                                     CategoryId = showId,
                                     ReactionTypeId = reactionTypeId,
                                     DateTime = registDt
                                 };
                                 context.ShowReactions.Add(reaction);
                             }
                         }
                         else
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "remove", true) == 0)
                                 context.ShowReactions.Remove(show);
                         }
                         returnValue = context.SaveChanges();
                         break;
                     }
                 case "episode":
                     {
                         var episodeId = Convert.ToInt32(idx);
                         var episode = context.EpisodeReactions.FirstOrDefault(i => i.EpisodeId == episodeId && i.ReactionTypeId == reactionTypeId && i.UserId == userId);
                         if (episode == null)
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "add", true) == 0)
                             {
                                 var reaction = new EpisodeReaction()
                                 {
                                     UserId = userId,
                                     EpisodeId = episodeId,
                                     ReactionTypeId = reactionTypeId,
                                     DateTime = registDt
                                 };
                                 context.EpisodeReactions.Add(reaction);
                             }
                         }
                         else
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "remove", true) == 0)
                                 context.EpisodeReactions.Remove(episode);
                         }
                         returnValue = context.SaveChanges();
                         break;
                     }
                 case "celebrity":
                     {
                         var celebrityId = Convert.ToInt32(idx);
                         var celebrity = context.CelebrityReactions.FirstOrDefault(i => i.CelebrityId == celebrityId && i.ReactionTypeId == reactionTypeId && i.UserId == userId);
                         if (celebrity == null)
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "add", true) == 0)
                             {
                                 var reaction = new CelebrityReaction()
                                 {
                                     UserId = userId,
                                     CelebrityId = celebrityId,
                                     ReactionTypeId = reactionTypeId,
                                     DateTime = registDt
                                 };
                                 context.CelebrityReactions.Add(reaction);
                             }
                         }
                         else
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "remove", true) == 0)
                                 context.CelebrityReactions.Remove(celebrity);
                         }
                         returnValue = context.SaveChanges();
                         break;
                     }
                 case "channel":
                     {
                         var channelId = Convert.ToInt32(idx);
                         var channel = context.ChannelReactions.FirstOrDefault(i => i.ChannelId == channelId && i.ReactionTypeId == reactionTypeId && i.UserId == userId);
                         if (channel == null)
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "add", true) == 0)
                             {
                                 var reaction = new ChannelReaction()
                                 {
                                     UserId = userId,
                                     ChannelId = channelId,
                                     ReactionTypeId = reactionTypeId,
                                     DateTime = registDt
                                 };
                                 context.ChannelReactions.Add(reaction);
                             }
                         }
                         else
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "remove", true) == 0)
                                 context.ChannelReactions.Remove(channel);
                         }
                         returnValue = context.SaveChanges();
                         break;
                     }
                 case "youtube":
                     {
                         var youtubeId = idx;
                         var youtube = context.YouTubeReactions.FirstOrDefault(i => i.YouTubeId == youtubeId && i.ReactionTypeId == reactionTypeId && i.UserId == userId);
                         if (youtube == null)
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "add", true) == 0)
                             {
                                 var reaction = new YouTubeReaction()
                                 {
                                     UserId = userId,
                                     YouTubeId = youtubeId,
                                     ReactionTypeId = reactionTypeId,
                                     DateTime = registDt
                                 };
                                 context.YouTubeReactions.Add(reaction);
                             }
                         }
                         else
                         {
                             if (!String.IsNullOrEmpty(action) && String.Compare(action, "remove", true) == 0)
                                 context.YouTubeReactions.Remove(youtube);
                         }
                         returnValue = context.SaveChanges();
                         break;
                     }
             }
         }
     }
     catch (Exception e) { return Json(new { result = e.InnerException.Message }, JsonRequestBehavior.AllowGet); }
     return Json(new { result = returnValue }, JsonRequestBehavior.AllowGet);
 }
コード例 #17
0
        public ActionResult GetMostLovedCelebrities1()
        {
            List<MostLovedCelebritiesDisplay> mostLovedCelebrities = null;
            string jsonString = String.Empty;
            var cache = DataCache.Cache;
            //string cacheKey = "SEGMLC1:O;C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode();
            string cacheKey = "SEGMLC1:O;C:";
            try { jsonString = (string)cache[cacheKey]; }
            catch (Exception) { }
            try
            {
                if (String.IsNullOrEmpty(jsonString))
                {
                    mostLovedCelebrities = new List<MostLovedCelebritiesDisplay>();
                    var socialContext = new EngagementsEntities();
                    var context = new IPTV2Entities();
                    var mostLovedCelebrityReactions = socialContext.CelebrityReactionSummaries
                        .Where(rtId => rtId.ReactionTypeId == GlobalConfig.SOCIAL_LOVE)
                        .Select(celeb => new
                        {
                            celebrityId = celeb.CelebrityId,
                            totalLoved = celeb.Total7Days
                        }).ToList().OrderByDescending(celeb => celeb.totalLoved).Take(20);

                    try
                    {
                        int count = 0;
                        foreach (var item in mostLovedCelebrityReactions)
                        {
                            var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == item.celebrityId && c.StatusId == GlobalConfig.Visible);
                            if (celebrity != null)
                            {
                                mostLovedCelebrities.Add(new MostLovedCelebritiesDisplay()
                                {
                                    celebrityId = item.celebrityId,
                                    celebrityName = celebrity.FullName,
                                    totalLove = item.totalLoved
                                });
                                count++;
                            }
                            if (count > 4)
                                break;
                        }
                        var cacheDuration = new TimeSpan(4, 0, 0);
                        jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(mostLovedCelebrities);
                        cache.Put(cacheKey, jsonString, cacheDuration);
                    }
                    catch (Exception) { }
                }
                else
                    mostLovedCelebrities = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MostLovedCelebritiesDisplay>>(jsonString);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return Json(mostLovedCelebrities, JsonRequestBehavior.AllowGet);
        }
コード例 #18
0
        public ActionResult GetMostLovedEpisodes1()
        {
            List<MostLovedEpisodesDisplay> mostLovedEpisodes = null;
            string jsonString = String.Empty;
            var cache = DataCache.Cache;
            string cacheKey = "SEGMLE1:O;C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode();
            try { jsonString = (string)cache[cacheKey]; }
            catch (Exception) { }
            try
            {
                if (String.IsNullOrEmpty(jsonString))
                {
                    mostLovedEpisodes = new List<MostLovedEpisodesDisplay>();
                    var socialContext = new EngagementsEntities();
                    var context = new IPTV2Entities();
                    var mostLovedEpisodeReactions = socialContext.EpisodeReactionSummaries
                        .Where(rtId => rtId.ReactionTypeId == GlobalConfig.SOCIAL_LOVE)
                        .Select(e => new
                        {
                            EpisodeId = e.EpisodeId,
                            TotalLoved = e.Total7Days
                        }).ToList().OrderByDescending(e => e.TotalLoved).Take(20);

                    try
                    {
                        int count = 0;
                        foreach (var item in mostLovedEpisodeReactions)
                        {
                            Episode episode = context.Episodes.FirstOrDefault(e => e.EpisodeId == item.EpisodeId && e.OnlineStatusId == GlobalConfig.Visible);
                            if (episode != null)
                            {
                                var category = episode.EpisodeCategories.FirstOrDefault(ec => ec.CategoryId != GlobalConfig.FreeTvCategoryId);
                                if (category != null)
                                {
                                    mostLovedEpisodes.Add(new MostLovedEpisodesDisplay()
                                    {
                                        showId = category.CategoryId,
                                        showName = String.Compare(episode.EpisodeName, episode.EpisodeCode, true) == 0 ? category.Show.Description : episode.EpisodeName,
                                        dateAired = episode.DateAired.Value.ToString("MMM d, yyyy"),
                                        episodeId = episode.EpisodeId,
                                        episodeName = String.Compare(episode.EpisodeName, episode.EpisodeCode, true) == 0 ? episode.DateAired.Value.ToString("MMM d, yyyy") : episode.EpisodeName,
                                        totalLove = item.TotalLoved
                                    });
                                    count++;
                                }
                            }
                            if (count > 4)
                                break;
                        }
                        var cacheDuration = new TimeSpan(4, 0, 0);
                        jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(mostLovedEpisodes);
                        cache.Put(cacheKey, jsonString, cacheDuration);
                    }
                    catch (Exception) { }
                }
                else
                    mostLovedEpisodes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MostLovedEpisodesDisplay>>(jsonString);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return Json(mostLovedEpisodes, JsonRequestBehavior.AllowGet);
        }
コード例 #19
0
        public JsonResult GetMostLovedCelebrities()
        {
            try
            {
                var socialContext = new EngagementsEntities();
                var context = new IPTV2Entities();

                var mostLovedCelebrityReactions = socialContext.CelebrityReactions
                    .Where(rtId => rtId.ReactionTypeId == 12)
                    .GroupBy(celeb => celeb.CelebrityId)
                    .Select(celeb => new
                    {
                        celebrityId = celeb.Key,
                        totalLoved = celeb.Count()
                    }).ToList().OrderByDescending(celeb => celeb.totalLoved).Take(5);

                var mostLovedCelebrities = mostLovedCelebrityReactions.Join(
                    context.Celebrities,
                    cr => cr.celebrityId,
                    cc => cc.CelebrityId,
                    (cr, cc) => new { CelebrityReaction = cr, Celebrity = cc })
                    .Select(celebrity => new
                    {
                        celebrityName = celebrity.Celebrity.FullName,
                        celebrityId = celebrity.Celebrity.CelebrityId,
                        totalLove = celebrity.CelebrityReaction.totalLoved,
                        image = String.IsNullOrEmpty(celebrity.Celebrity.ImageUrl) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, celebrity.Celebrity.CelebrityId.ToString(), celebrity.Celebrity.ImageUrl),
                        description = celebrity.Celebrity.Description
                    });

                if (mostLovedCelebrities != null)
                    return Json(mostLovedCelebrities, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return null;
        }
コード例 #20
0
        public ActionResult List(int? id, string slug)
        {
            if (!Request.Cookies.AllKeys.Contains("version"))
            {
                if (id == null)
                    return RedirectToAction("Shows");
                try
                {
                    using (var context = new IPTV2Entities())
                    {
                        var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id && c.StatusId == GlobalConfig.Visible);
                        if (category != null)
                        {
                            if (category is Category)
                            {
                                try
                                {
                                    var parents = category.CategoryClassParentCategories.Select(c => c.ParentCategory.Description);
                                    var daxParent = parents.Intersect(GlobalConfig.DaxAllowedParentCategories.Split(','), StringComparer.InvariantCultureIgnoreCase);
                                    ViewBag.ParentCategory = string.Join(",", daxParent).ToLower();
                                }
                                catch (Exception) { }

                                ViewBag.id = id;
                                ViewBag.SectionTitle = category.Description;
                                return View("List2", category);
                            }
                        }
                    }
                }
                catch (Exception) { }
            }

            try
            {
                if (id == null)
                    return RedirectToAction("Index", "Home");

                if (id != null)
                    if (id == GlobalConfig.OnlinePremiereCategoryId)
                        return RedirectPermanent("/OnlinePremiere");


                var profiler = MiniProfiler.Current;

                var cache = DataCache.Cache;
                //string cacheKey = "CATLIST:O:" + id.ToString() + ";C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode();

                var socialcontext = new EngagementsEntities();
                var context = new IPTV2Entities();
                var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId);
                var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
                DateTime registDt = DateTime.Now;
                //Category category = (Category)cache[cacheKey];

                //if (category == null)
                //{
                Category category = (Category)context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id && c.StatusId == GlobalConfig.Visible);
                if (category != null)
                {
                    var dbSlug = MyUtility.GetSlug(category.Description);
                    if (String.Compare(dbSlug, slug, false) != 0)
                        return RedirectToActionPermanent("List", new { id = id, slug = dbSlug });

                    SortedSet<int> showIds = service.GetAllOnlineShowIds(MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode(), category);
                    ViewBag.Category = category.Description;
                    ViewBag.CategoryModel = category;

                    if (showIds.Count() == 0)
                        return RedirectToAction("Index", "Home");

                    int[] setofShows = showIds.ToArray();
                    var list = context.CategoryClasses.Where(c => setofShows.Contains(c.CategoryId) && c.StartDate <= registDt && c.EndDate >= registDt && c.StatusId == GlobalConfig.Visible).OrderBy(c => c.CategoryName).ThenBy(c => c.StartDate).ToList();
                    // cache.Put(cacheKey, list, DataCache.CacheDuration);
                    //using (profiler.Step("Episode Count"))
                    //{
                    //    var social_list = socialcontext.ShowReactions
                    //        .GroupBy(c => new { c.CategoryId, c.ReactionTypeId }, (key, group) => new
                    //        {
                    //            CategoryId = key.CategoryId,
                    //            TotalLoves = key.ReactionTypeId == GlobalConfig.SOCIAL_LOVE ? group.Count() : 0,
                    //            TotalComments = key.ReactionTypeId == GlobalConfig.SOCIAL_COMMENT ? group.Count() : 0
                    //        }).GroupBy(c => c.CategoryId).ToList();
                    //}

                    string cacheKey2 = "CATLISTDISP:O:" + id.ToString() + ";C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode();

                    List<CategoryShowListDisplay> catList = (List<CategoryShowListDisplay>)cache[cacheKey2];
                    if (catList == null)
                    {
                        //List<CategoryShowListDisplay> catList = new List<CategoryShowListDisplay>();
                        catList = new List<CategoryShowListDisplay>();
                        using (profiler.Step("Sort By Module"))
                        {
                            foreach (var item in list)
                            {
                                var ratingsCountSummary = socialcontext.ShowReactionSummaries.FirstOrDefault(i => i.CategoryId == item.CategoryId && i.ReactionTypeId == GlobalConfig.SOCIAL_RATING);
                                var likesCountSummary = socialcontext.ShowReactionSummaries.FirstOrDefault(i => i.CategoryId == item.CategoryId && i.ReactionTypeId == GlobalConfig.SOCIAL_LIKE);
                                var lovesCountSummary = socialcontext.ShowReactionSummaries.FirstOrDefault(i => i.CategoryId == item.CategoryId && i.ReactionTypeId == GlobalConfig.SOCIAL_LOVE);
                                var commentsCountSummary = socialcontext.ShowReactionSummaries.FirstOrDefault(i => i.CategoryId == item.CategoryId && i.ReactionTypeId == GlobalConfig.SOCIAL_COMMENT);
                                catList.Add(new CategoryShowListDisplay
                                {
                                    CategoryId = item.CategoryId,
                                    Description = item.Description,
                                    ImagePoster = item.ImagePoster,
                                    AiredDate = item.StartDate,
                                    Ratings = (Decimal?)(ratingsCountSummary == null ? 0 : ratingsCountSummary.Total),
                                    TotalLikes = (int?)(likesCountSummary == null ? 0 : likesCountSummary.Total),
                                    TotalLoves = (int?)(lovesCountSummary == null ? 0 : lovesCountSummary.Total),
                                    TotalComments = (int?)(commentsCountSummary == null ? 0 : commentsCountSummary.Total)
                                });
                            }
                        }
                        var cacheDuration = new TimeSpan(0, GlobalConfig.MenuCacheDuration, 0);
                        cache.Put(cacheKey2, catList, cacheDuration);
                    }
                    ViewBag.dbSlug = dbSlug;
                    return View(catList);
                }
            }
            //}

            catch (Exception) { throw; }

            return RedirectToAction("Index", "Home");
        }
コード例 #21
0
        public void FillMostLovedShowCache(IPTV2Entities context, EngagementsEntities socialContext, int offeringId, int serviceId, TimeSpan cacheDuration, int SOCIAL_LOVE, int Entertainment)
        {
            List<MostLovedShowsDisplay> mostLovedShows = null;
            try
            {
                var countries = context.Countries.ToList();

                var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == offeringId);
                var service = offering.Services.FirstOrDefault(s => s.PackageId == serviceId);

                foreach (var c in countries)
                {
                    try
                    {
                        string cacheKey = "SEGMLS1:O;C:" + c.Code;
                        mostLovedShows = new List<MostLovedShowsDisplay>();
                        Category category = (Category)context.CategoryClasses.FirstOrDefault(cc => cc.CategoryId == Entertainment && cc.StatusId == 1);
                        if (category != null)
                        {
                            SortedSet<int> showIds = service.GetAllOnlineShowIds(c.Code, category);

                            //var showReactions = socialContext.ShowReactions
                            //.Where(cc => cc.ReactionTypeId == SOCIAL_LOVE && showIds.Contains(cc.CategoryId))
                            //.GroupBy(cc => cc.CategoryId)
                            //.Select(cc => new
                            //{
                            //    categoryId = cc.Key,
                            //    totalLove = cc.Count()
                            //}).ToList().OrderByDescending(cc => cc.totalLove).Take(5);
                            var showReactions = socialContext.ShowReactionSummaries
                                .Where(cc => cc.ReactionTypeId == SOCIAL_LOVE && showIds.Contains(cc.CategoryId))
                                .Select(cc => new
                                {
                                    categoryId = cc.CategoryId,
                                    totalLove = cc.Total7Days
                                }).ToList().OrderByDescending(cc => cc.totalLove).Take(5);

                            try
                            {
                                foreach (var item in showReactions)
                                {
                                    var categoryClass = context.CategoryClasses.FirstOrDefault(cc => cc.CategoryId == item.categoryId);
                                    if (categoryClass != null)
                                    {
                                        try
                                        {
                                            mostLovedShows.Add(new MostLovedShowsDisplay()
                                            {
                                                categoryId = item.categoryId,
                                                totalLove = item.totalLove,
                                                categoryName = categoryClass.Description,
                                                slug = GetSlug(categoryClass.Description)
                                            });
                                        }
                                        catch (Exception e) { Trace.Fail(e.Message); }
                                    }
                                }
                                var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(mostLovedShows);
                                DataCache.Cache.Put(cacheKey, jsonString, cacheDuration);
                            }
                            catch (Exception e) { Trace.Fail(e.Message); }
                        }
                    }
                    catch (Exception e) { Trace.Fail(e.Message); }
                }
            }
            catch (Exception e) { Trace.Fail(e.Message); }
        }
コード例 #22
0
        public JsonResult CreateInteraction(FormCollection fc)
        {
            var ReturnCode = new TransactionReturnType()
            {
                StatusCode = (int)ErrorCodes.UnknownError,
                StatusMessage = String.Empty
            };
            try
            {
                if (User.Identity.IsAuthenticated)
                {
                    Dictionary<string, string> tmpCollection = fc.AllKeys.ToDictionary(k => k, v => fc[v]);
                    bool isMissingRequiredFields = false;

                    foreach (var x in tmpCollection)
                    {
                        if (String.IsNullOrEmpty(x.Value))
                        {
                            isMissingRequiredFields = true;
                            break;
                        }
                    }

                    if (!isMissingRequiredFields) // process form
                    {
                        int reactionId = Convert.ToInt32(fc["reactionId"]);
                        string type = fc["type"];
                        int id = Convert.ToInt32(fc["id"]);
                        var UserId = new Guid(User.Identity.Name);
                        var registDt = DateTime.Now;
                        using (var context = new EngagementsEntities())
                        {
                            switch (type)
                            {
                                case "show":
                                    if (reactionId == GlobalConfig.SOCIAL_LOVE) //12 Is Social_Love
                                    {
                                        int click = Convert.ToInt32(fc["click"]);
                                        var reaction = context.ShowReactions.FirstOrDefault(i => i.CategoryId == id && i.ReactionTypeId == reactionId && i.UserId == UserId);
                                        if (reaction != null || click == 0)
                                            context.ShowReactions.Remove(reaction);
                                        else
                                        {
                                            reaction = new ShowReaction()
                                            {
                                                UserId = UserId,
                                                CategoryId = id,
                                                ReactionTypeId = reactionId,
                                                DateTime = registDt
                                            };
                                            context.ShowReactions.Add(reaction);
                                        }
                                    }
                                    else
                                    {
                                        var reaction = new ShowReaction()
                                        {
                                            UserId = UserId,
                                            CategoryId = id,
                                            ReactionTypeId = reactionId,
                                            DateTime = registDt
                                        };
                                        context.ShowReactions.Add(reaction);
                                    }
                                    break;
                                case "episode":
                                    if (reactionId == GlobalConfig.SOCIAL_LOVE) //12 Is Social_Love
                                    {
                                        int click = Convert.ToInt32(fc["click"]);
                                        var reaction = context.EpisodeReactions.FirstOrDefault(i => i.EpisodeId == id && i.ReactionTypeId == reactionId && i.UserId == UserId);
                                        if (reaction != null || click == 0)
                                            context.EpisodeReactions.Remove(reaction);
                                        else
                                        {
                                            reaction = new EpisodeReaction()
                                            {
                                                UserId = UserId,
                                                EpisodeId = id,
                                                ReactionTypeId = reactionId,
                                                DateTime = registDt
                                            };
                                            context.EpisodeReactions.Add(reaction);
                                        }
                                    }
                                    else
                                    {
                                        var reaction = new EpisodeReaction()
                                        {
                                            UserId = UserId,
                                            EpisodeId = id,
                                            ReactionTypeId = reactionId,
                                            DateTime = registDt
                                        };
                                        context.EpisodeReactions.Add(reaction);
                                    }
                                    break;
                                case "celebrity":
                                    if (reactionId == GlobalConfig.SOCIAL_LOVE) //12 Is Social_Love
                                    {
                                        int click = Convert.ToInt32(fc["click"]);
                                        var reaction = context.CelebrityReactions.FirstOrDefault(i => i.CelebrityId == id && i.ReactionTypeId == reactionId && i.UserId == UserId);
                                        if (reaction != null || click == 0)
                                            context.CelebrityReactions.Remove(reaction);
                                        else
                                        {
                                            reaction = new CelebrityReaction()
                                            {
                                                UserId = UserId,
                                                CelebrityId = id,
                                                ReactionTypeId = reactionId,
                                                DateTime = registDt
                                            };
                                            context.CelebrityReactions.Add(reaction);
                                        }
                                    }
                                    else
                                    {
                                        var reaction = new CelebrityReaction()
                                        {
                                            UserId = UserId,
                                            CelebrityId = id,
                                            ReactionTypeId = reactionId,
                                            DateTime = registDt
                                        };
                                        context.CelebrityReactions.Add(reaction);
                                    }
                                    break;
                            }

                            context.SaveChanges();
                        }
                    }

                }
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return Json(ReturnCode, JsonRequestBehavior.AllowGet);
        }
コード例 #23
0
        public void FillMostLovedCelebrityCache1(IPTV2Entities context, EngagementsEntities socialContext, int offeringId, int serviceId, TimeSpan cacheDuration, int SOCIAL_LOVE)
        {
            List<MostLovedCelebritiesDisplay> mostLovedCelebrities = null;
            try
            {
                try
                {
                    string cacheKey = "SEGMLC1:O;C:";
                    mostLovedCelebrities = new List<MostLovedCelebritiesDisplay>();
                    var mostLovedCelebrityReactions = socialContext.CelebrityReactionSummaries
                        .Where(rtId => rtId.ReactionTypeId == SOCIAL_LOVE)
                        .Select(celeb => new
                        {
                            celebrityId = celeb.CelebrityId,
                            totalLoved = celeb.Total7Days
                        }).ToList().OrderByDescending(celeb => celeb.totalLoved).Take(20);

                    try
                    {
                        int count = 0;
                        foreach (var item in mostLovedCelebrityReactions)
                        {

                            var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == item.celebrityId && c.StatusId == 1);
                            if (celebrity != null)
                            {
                                try
                                {
                                    mostLovedCelebrities.Add(new MostLovedCelebritiesDisplay()
                                    {
                                        celebrityId = item.celebrityId,
                                        celebrityName = celebrity.FullName,
                                        totalLove = item.totalLoved,
                                        slug = GetSlug(celebrity.FullName)
                                    });
                                    count++;
                                }
                                catch (Exception e) { Trace.Fail(e.Message); }

                            }
                            if (count > 4)
                                break;
                        }
                        var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(mostLovedCelebrities);
                        DataCache.Cache.Put(cacheKey, jsonString, cacheDuration);
                    }
                    catch (Exception e) { Trace.Fail(e.Message); }
                }
                catch (Exception e) { Trace.Fail(e.Message); }
            }
            catch (Exception) { }
        }
コード例 #24
0
        public ActionResult GetUserLovedShows(Guid id)
        {
            var socialContext = new EngagementsEntities();
            var context = new IPTV2Entities();

            var userLovedShows = socialContext.ShowReactions
                .Where(show => show.UserId == id && show.ReactionTypeId == GlobalConfig.SOCIAL_LOVE)
                .Select(show => new
                {
                    categoryId = show.CategoryId
                }).Distinct().ToList();

            var lovedShows = userLovedShows.Join(
                    context.CategoryClasses,
                    ls => ls.categoryId,
                    cc => cc.CategoryId,
                    (sr, cc) => new { ShowReaction = sr, CategoryClasses = cc })
                    .Select(show => new
                    {
                        ShowName = show.CategoryClasses.CategoryName,
                        ShowId = show.CategoryClasses.CategoryId,
                        ShowImageUrl = GlobalConfig.ShowImgPath + show.CategoryClasses.CategoryId + "/" + show.CategoryClasses.ImagePoster,
                    });

            if (lovedShows != null)
                return Json(lovedShows, JsonRequestBehavior.AllowGet);

            return null;
        }
コード例 #25
0
        public void FillMostLovedEpisodeCache(IPTV2Entities context, EngagementsEntities socialContext, int offeringId, int serviceId, TimeSpan cacheDuration, int SOCIAL_LOVE, int FreeTvCategoryId)
        {
            List<MostLovedEpisodesDisplay> mostLovedEpisodes = null;
            try
            {
                var countries = context.Countries.ToList();
                foreach (var c in countries)
                {
                    try
                    {
                        string cacheKey = "SEGMLE1:O;C:" + c.Code;
                        mostLovedEpisodes = new List<MostLovedEpisodesDisplay>();

                        //var mostLovedEpisodeReactions = socialContext.EpisodeReactions
                        //    .Where(rtId => rtId.ReactionTypeId == SOCIAL_LOVE)
                        //    .GroupBy(e => e.EpisodeId)
                        //    .Select(e => new
                        //    {
                        //        EpisodeId = e.Key,
                        //        TotalLoved = e.Count()
                        //    }).ToList().OrderByDescending(e => e.TotalLoved).Take(5);
                        var mostLovedEpisodeReactions = socialContext.EpisodeReactionSummaries
                            .Where(rtId => rtId.ReactionTypeId == SOCIAL_LOVE)
                            .Select(e => new
                            {
                                EpisodeId = e.EpisodeId,
                                TotalLoved = e.Total7Days
                            }).ToList().OrderByDescending(e => e.TotalLoved).Take(20);

                        try
                        {
                            int count = 0;
                            foreach (var item in mostLovedEpisodeReactions)
                            {
                                Episode episode = context.Episodes.FirstOrDefault(e => e.EpisodeId == item.EpisodeId && e.OnlineStatusId == 1);
                                if (episode != null)
                                {
                                    var category = episode.EpisodeCategories.FirstOrDefault(ec => ec.CategoryId != FreeTvCategoryId);
                                    if (category != null)
                                    {
                                        try
                                        {
                                            mostLovedEpisodes.Add(new MostLovedEpisodesDisplay()
                                            {
                                                showId = category.CategoryId,
                                                showName = String.Compare(episode.EpisodeName, episode.EpisodeCode, true) == 0 ? category.Show.Description : episode.EpisodeName,
                                                dateAired = episode.DateAired.Value.ToString("MMMM dd, yyyy"),
                                                episodeId = episode.EpisodeId,
                                                episodeName = String.Compare(episode.EpisodeName, episode.EpisodeCode, true) == 0 ? episode.DateAired.Value.ToString("MMM dd, yyyy") : episode.EpisodeName,
                                                totalLove = item.TotalLoved,
                                                slug = GetSlug(episode.IsLiveChannelActive == true ? episode.Description : String.Format("{0} {1}", category.Show.Description, episode.DateAired.Value.ToString("MMMM d yyyy"))),
                                                showSlug = GetSlug(category.Show.Description)
                                            });
                                            count++;
                                        }
                                        catch (Exception e) { Trace.Fail(e.Message); }
                                    }
                                }
                                if (count > 4)
                                    break;
                            }
                            var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(mostLovedEpisodes);
                            DataCache.Cache.Put(cacheKey, jsonString, cacheDuration);
                        }
                        catch (Exception e) { Trace.Fail(e.Message); }
                    }
                    catch (Exception e) { Trace.Fail(e.Message); }
                }
            }
            catch (Exception e) { Trace.Fail(e.Message); }
        }
コード例 #26
0
        public ActionResult GetTopReviewers()
        {
            var socialContext = new EngagementsEntities();
            var context = new IPTV2Entities();

            var topReviewersAll = socialContext.EpisodeReactions
                .Where(rtId => rtId.ReactionTypeId == GlobalConfig.SOCIAL_RATING)
                .Select(user => new { user.UserId, user.Reactionid })
                .Union(socialContext.ShowReactions.Where(rtId => rtId.ReactionTypeId == GlobalConfig.SOCIAL_RATING)
                .Select(user => new { user.UserId, user.Reactionid })).GroupBy(user => user.UserId)
                .Select(user => new
                {
                    userId = user.Key,
                    totalReview = user.Count()
                }).ToList().OrderByDescending(user => user.totalReview).Take(5);

            var topReviewers = topReviewersAll.Join(
                context.Users,
                tr => tr.userId,
                user => user.UserId,
                (tr, user) => new { TopReviewer = tr, User = user })
                .Select(u => new
                {
                    userInternalId = u.User.InternalUserId,
                    userId = u.User.UserId,
                    gigyaId = u.User.GigyaUID,
                    userName = u.User.FirstName + " " + u.User.LastName,
                    totalReview = u.TopReviewer.totalReview,
                    userPhoto = GetUserImage(u.User.UserId)
                });

            if (topReviewers != null)
                return Json(topReviewers, JsonRequestBehavior.AllowGet);

            return null;
        }
コード例 #27
0
        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);
        }
コード例 #28
0
        public ActionResult GetMostLovedShows1()
        {
            List<MostLovedShowsDisplay> mostLovedShows = null;
            string jsonString = String.Empty;
            var cache = DataCache.Cache;
            string cacheKey = "SEGMLS1:O;C:" + MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode();
            try { jsonString = (string)cache[cacheKey]; }
            catch (Exception) { }
            try
            {
                if (String.IsNullOrEmpty(jsonString))
                {
                    mostLovedShows = new List<MostLovedShowsDisplay>();
                    var socialContext = new EngagementsEntities();
                    var context = new IPTV2Entities();
                    var offering = context.Offerings.FirstOrDefault(o => o.OfferingId == GlobalConfig.offeringId);
                    var service = offering.Services.FirstOrDefault(s => s.PackageId == GlobalConfig.serviceId);
                    Category category = (Category)context.CategoryClasses.FirstOrDefault(c => c.CategoryId == GlobalConfig.Entertainment && c.StatusId == GlobalConfig.Visible);
                    if (category != null)
                    {
                        SortedSet<int> showIds = service.GetAllOnlineShowIds(MyUtility.getCountry(Request.GetUserHostAddressFromCloudflare()).getCode(), category);
                        var showReactions = socialContext.ShowReactionSummaries
                        .Where(c => c.ReactionTypeId == GlobalConfig.SOCIAL_LOVE && showIds.Contains(c.CategoryId))
                        .Select(c => new
                        {
                            categoryId = c.CategoryId,
                            totalLove = c.Total7Days
                        }).ToList().OrderByDescending(c => c.totalLove).Take(5);

                        try
                        {
                            foreach (var item in showReactions)
                            {
                                var categoryClass = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == item.categoryId);
                                if (categoryClass != null)
                                {
                                    mostLovedShows.Add(new MostLovedShowsDisplay()
                                    {
                                        categoryId = item.categoryId,
                                        totalLove = item.totalLove,
                                        categoryName = categoryClass.Description
                                    });
                                }
                            }
                            var cacheDuration = new TimeSpan(4, 0, 0);
                            jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(mostLovedShows);
                            cache.Put(cacheKey, jsonString, cacheDuration);
                        }
                        catch (Exception) { }
                    }
                }
                else
                    mostLovedShows = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MostLovedShowsDisplay>>(jsonString);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return Json(mostLovedShows, JsonRequestBehavior.AllowGet);
        }
コード例 #29
0
        public JsonResult GetReactionCount(int reactionId, string type, int id)
        {
            var ReturnCode = new TransactionReturnType()
            {
                StatusCode = (int)ErrorCodes.UnknownError,
                StatusMessage = String.Empty,
            };

            try
            {
                int reactionCount = 0;
                using (var context = new EngagementsEntities())
                {
                    switch (type)
                    {
                        case "show":
                            reactionCount = context.ShowReactions.Count(i => i.CategoryId == id && i.ReactionTypeId == reactionId);
                            break;
                        case "episode":
                            reactionCount = context.EpisodeReactions.Count(i => i.EpisodeId == id && i.ReactionTypeId == reactionId);
                            break;
                        case "celebrity":
                            reactionCount = context.CelebrityReactions.Count(i => i.CelebrityId == id && i.ReactionTypeId == reactionId);
                            break;
                    }
                }
                ReturnCode.StatusCode = (int)ErrorCodes.Success;
                ReturnCode.StatusMessage = String.Format("{0}", reactionCount);
            }
            catch (Exception e) { MyUtility.LogException(e); }
            return Json(ReturnCode, JsonRequestBehavior.AllowGet);
        }
コード例 #30
0
        public ActionResult GetMostLovedCelebrities()
        {
            var socialContext = new EngagementsEntities();
            var context = new IPTV2Entities();

            var mostLovedCelebrityReactions = socialContext.CelebrityReactions
                .Where(rtId => rtId.ReactionTypeId == GlobalConfig.SOCIAL_LOVE)
                .GroupBy(celeb => celeb.CelebrityId)
                .Select(celeb => new
                {
                    celebrityId = celeb.Key,
                    totalLoved = celeb.Count()
                }).ToList().OrderByDescending(celeb => celeb.totalLoved).Take(5);

            var mostLovedCelebrities = mostLovedCelebrityReactions.Join(
                context.Celebrities,
                cr => cr.celebrityId,
                cc => cc.CelebrityId,
                (cr, cc) => new { CelebrityReaction = cr, Celebrity = cc })
                .Select(celebrity => new
                {
                    celebrityName = celebrity.Celebrity.FullName,
                    celebrityId = celebrity.Celebrity.CelebrityId,
                    totalLove = celebrity.CelebrityReaction.totalLoved
                });

            if (mostLovedCelebrities != null)
                return Json(mostLovedCelebrities, JsonRequestBehavior.AllowGet);

            return null;
        }