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; }
        }
Example #2
0
        public ActionResult Teams(int? id)
        {
            try
            {
                if (!Request.Cookies.AllKeys.Contains("version"))
                    return View("Teams2");

                List<Celebrity> jfi = null;
                var socialContext = new EngagementsEntities();
                var cache = DataCache.Cache;
                string cacheKey = "UaapCelebCacKey1:0;" + id;
                jfi = (List<Celebrity>)cache[cacheKey];

                if (jfi == null)
                {
                    var context = new IPTV2Entities();
                    var feature = context.Features.FirstOrDefault(f => f.FeatureId == 82 && f.StatusId == GlobalConfig.Visible);

                    List<FeatureItem> featureItems = feature.FeatureItems.Where(f => f.StatusId == GlobalConfig.Visible).ToList();
                    List<int> idlist = new List<int>();
                    foreach (CelebrityFeatureItem f in featureItems)
                    {
                        idlist.Add(f.CelebrityId);
                    }

                    var celeb = context.Celebrities.Where(c => idlist.Contains(c.CelebrityId));
                    jfi = new List<Celebrity>();
                    foreach (Celebrity person in celeb)
                    {
                        bool hasLoved = MyUtility.isUserLoggedIn() && HasSocialEngagementRecordOnCelebrity(new System.Guid(User.Identity.Name), GlobalConfig.SOCIAL_LOVE, (int)person.CelebrityId);
                        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, Height = person.Height, FullName = person.FullName, Birthday = person.Birthday, Birthplace = hasLoved.ToString() };
                        jfi.Add(c);
                    }
                    cache.Put(cacheKey, jfi, DataCache.CacheDuration);
                }
                return View(jfi);
            }
            catch (Exception) { throw; }

        }