Esempio 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));
        }
Esempio n. 2
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()));

            //设置当前登录用户对当前页用户的关注情况
            Dictionary <long, bool> isCurrentUserFollowDic = new Dictionary <long, bool>();

            foreach (var user in hotUsers)
            {
                //如果当前登录用户关注了该用户
                if (followService.IsFollowed(CurrentUser.UserId, user.UserId))
                {
                    isCurrentUserFollowDic.Add(user.UserId, true);
                }
                else
                {
                    isCurrentUserFollowDic.Add(user.UserId, false);
                }
            }
            ViewData["isCurrentUserFollowDic"] = isCurrentUserFollowDic;
            ViewData["userName"] = CurrentUser.UserName;
            pageResourceManager.InsertTitlePart("可能感兴趣的人");

            return(View(hotUsers));
        }