示例#1
0
        public List <UserTweetsVM> GetUserTweets(int userID)
        {
            List <UserTweetsVM> lista = db.tsp_UserTweets(userID).Select(x => new UserTweetsVM
            {
                userID              = (int)x.UserID,
                content             = x.Content,
                datetime            = (DateTime)x.TweetDate,
                likeCount           = (int)x.likeCount,
                nickname            = x.Nickname,
                imgTweet            = x.TweetImg,
                profileImg          = x.ProfileImage,
                retweetCount        = (int)x.retweetCount,
                username            = x.Username,
                tweetID             = (int)x.TweetID,
                parentTweetUsername = x.ParentTweetUsername
            }).ToList();

            foreach (var item in db.tsp_ReplyCount().ToList())
            {
                foreach (var tweet in lista)
                {
                    if (tweet.tweetID == item.TweetID)
                    {
                        tweet.replyCount = (int)item.ReplyCount;
                        break;
                    }
                }
            }
            return(lista);
        }