Exemplo n.º 1
0
        /// <summary>
        /// 可能感兴趣的人
        /// </summary>
        /// <returns></returns>
        public ActionResult Interested()
        {
            IUser CurrentUser = UserContext.CurrentUser;
            if (CurrentUser == null)
            {
                return Redirect(SiteUrls.Instance().Login());
            }

            // 没有感兴趣的人时,推荐人气用户,需去除已关注用户和自己
            //根据点击数取热门用户
            IEnumerable<IUser> topUsers = userService.GetTopUsers(100, SortBy_User.HitTimes);

            //已关注用户
            IEnumerable<long> followedUserIds = followService.GetTopFollowedUserIds(CurrentUser.UserId, 1000);

            //黑名单用户
            IEnumerable<long> stopUserIds = new PrivacyService().GetStopedUsers(CurrentUser.UserId).Select(n => n.Key);

            //去除已关注用户和加黑名单用户
            IEnumerable<IUser> hotUsers = topUsers.Where(n => !followedUserIds.Contains(n.UserId) && n.UserId != CurrentUser.UserId && !stopUserIds.Contains(n.UserId)).Take(Math.Min(8, topUsers.Count()));
            ViewData["userName"] = CurrentUser.UserName;
            pageResourceManager.InsertTitlePart("可能感兴趣的人");

            return View(hotUsers);
        }