Exemplo n.º 1
0
        public HttpResponseMessage GetUserFollowees()
        {
            var userToken = HttpContext.Current.User.Identity.Name;
            var userEmail = TokenManager.GetEmailFromToken(userToken);
            var user      = _userManager.GetUserByEmail(userEmail);

            if (user != null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, _followManager.GetUserFollowees(user.Key).Select(uf => uf.ToUserDto())));
                //return tweets.ToPaginatedDto(tweets.Select(tw => tw.ToTweetDto()));
            }
            return(Request.CreateResponse(HttpStatusCode.Unauthorized));
        }
Exemplo n.º 2
0
        public IEnumerable <Tweet> GetUserDashboardTweets(Guid userKey)
        {
            var user = _membershipService.GetUser(userKey);

            if (user == null)
            {
                return(null);
            }

            //List<Tweet> tweets = new List<Tweet>();

            ////adding tweets of user
            //tweets.AddRange(user.Tweets);

            ////adding tweets of user followees
            //var userFollowees = _followManager.GetUserFollowees(user.Key);

            //foreach (var userFollowee in userFollowees)
            //{
            //    tweets.AddRange(userFollowee.Tweets);
            //}
            //return tweets;

            var tweets = user.Tweets;

            foreach (var tweet in tweets)
            {
                var hashtags = tweet.TweetHashtags;
                Console.WriteLine(hashtags);
            }

            var userFollowees = _followManager.GetUserFollowees(user.Key);

            foreach (var userFollowee in userFollowees)
            {
                foreach (var tweet in userFollowee.Tweets)
                {
                    tweets.Add(tweet);
                }
            }
            return(tweets.OrderByDescending(t => t.CreatedOn));
        }