Exemplo n.º 1
0
        /// <summary>
        /// Get Trending Content Of Culture
        /// </summary>
        /// <param name="pageIndex">Page Index of Loaded Content</param>
        /// <param name="pageSize">Page Size of Loaded Content</param>
        /// <param name="culture">Culture Code (Default "WW"-Worldwide)</param>
        /// <returns>TrendingReturnModel</returns>
        public TrendingGroupsReturnModel GetTrendingGroups(int pageIndex, int pageSize, string currUserId, string culture = "WW")
        {
            TrendingGroupsReturnModel model = new TrendingGroupsReturnModel();
            var popularGroups = _popularitySet.AsNoTracking()
                                .Where(p => p.CultureCode == culture && p.GroupId != null)
                                .OrderByDescending(p => p.PopularityLevel)
                                .Skip((pageIndex - 1) * pageSize)
                                .Take(pageSize).Select(f => f.GroupId).ToArray();

            int popularGroupCount = _popularitySet.AsNoTracking().Where(f => f.OnTrendingStartUtcTime != null && f.OnTrendingEndUtcTime == null && f.GroupId != null).Count();


            model.Groups = _groupSet.AsNoTracking()
                           .Include(p => p.UsersFollowing).Include(p => p.ProfileImage).Include(p => p.CoverImage)
                           .Where(p => popularGroups.Contains(p.Id))
                           .Select(p => new InterestCard()
            {
                CoverImage             = p.CoverImage.ThumbPath,
                FollowerCount          = p.UsersFollowing.Count(),
                IsCurrentUserFollowing = p.UsersFollowing.Any(f => f.UserId == currUserId),
                Name         = p.Name,
                ProfileImage = p.ProfileImage.SmallPath,
                UrlKey       = p.UrlKey,
                Id           = p.Id
            })
                           .ToPaginatedList(pageIndex, pageSize, popularGroupCount);

            return(model);
        }
Exemplo n.º 2
0
        public TrendingGroupsReturnModel GetGroups([FromQuery] int pageSize, int pageIndex, string culture)
        {
            TrendingGroupsReturnModel model = new TrendingGroupsReturnModel();
            var   user    = HttpContext.User;
            Claim idClaim = User.FindFirst("sub");

            if (string.IsNullOrEmpty(culture))
            {
                culture = "WW";
            }
            if (idClaim != null)
            {
                return(_trendingDataService.GetTrendingGroups(pageIndex, pageSize, idClaim.Value, culture));
            }
            else
            {
                return(_trendingDataService.GetTrendingGroups(pageIndex, pageSize, null, culture));
            }
        }