public List <UserTweetsVM> GetTweets(int userID) { List <UserTweetsVM> lista = db.tsp_AllTweets(userID).Select(x => new UserTweetsVM { userID = (int)x.UserID, content = x.Content, datetime = (DateTime)x.TweetDate, likeCount = (int)x.likeCount, nickname = x.Nickname, profileImg = x.ProfileImage, retweetCount = (int)x.retweetCount, imgTweet = x.TweetImg, 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); }
public List <UserTweetsVM> GetMentions(int userID) { List <UserTweetsVM> lista = db.tsp_UserMentions(userID).Select(x => new UserTweetsVM { profileImg = x.ProfileImage, likeCount = (int)x.likeCount, nickname = x.Nickname, content = x.TweetContent, replyUsername = x.UsernameMention, retweetCount = (int)x.retweetCount, datetime = (DateTime)x.TweetDate, username = x.Username, tweetID = (int)x.tweetID, userID = (int)x.userID, replyUserID = x.userReplyID, imgTweet = x.TweetImg }).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; } } } if (lista.Count == 0) { return(null); } return(lista); }