public FriendExtraInfo Get(string id)
        {
            var fbHelper = new FaceBookHelper(AuthToken, UserId);
            var friend   = fbHelper.GetFriendExtendedInfo(id);

            return(friend != null
                ? new FriendExtraInfo
            {
                LastStatusUpdate = friend.message,
                LastStatusId = friend.message_id,
                LastStatusUpdateDateTime = friend.message_datetime,
                DaysUntilBirthday = GetDaysUntilBirthday(friend.birthday)
            }
                : null);
        }
示例#2
0
        // GET api/friends/5
        public FriendInfoCard Get(int id)
        {
            var fbHelper = new FaceBookHelper(AuthToken, UserId);

            var allFriends =
                fbHelper.GetRankedFriends()
                .Select(
                    friend =>
                    new FriendInfoCard
            {
                FriendId = friend.uid,
                FullName = friend.name,
                VirtualInteractionScore  = friend.virtualRank,
                PhysicalInteractionScore = friend.physicalRank,
                ProfilePictureImagePath  = friend.pic_big,
                LastInteractionTime      = friend.lastInteractionTime
            })
                .OrderByDescending(friend => friend.TotalInteractionScore)
                .ThenBy(friend => friend.FullName)
                .ToList();

            if (allFriends.Any() == false)
            {
                return(null);
            }

            id = id % allFriends.Count();
            if (id < 1)
            {
                id = allFriends.Count();
            }
            var friendToReturn = allFriends[id - 1];

            friendToReturn.FriendRank = id;
            return(friendToReturn);
        }