Beispiel #1
0
        public List <UserTweetsVM> SearchTweets(string word)
        {
            List <UserTweetsVM> lista = db.tsp_AllTweetsEveryone().Select(x => new UserTweetsVM
            {
                userID              = (int)x.UserID,
                content             = x.Content,
                datetime            = (DateTime)x.TweetDate,
                likeCount           = (int)x.likeCount,
                imgTweet            = x.TweetImg,
                nickname            = x.Nickname,
                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;
                    }
                }
            }

            List <UserTweetsVM> lista2 = new List <UserTweetsVM>();

            foreach (UserTweetsVM item in lista)
            {
                try
                {
                    if (item.content.Contains(word))
                    {
                        lista2.Add(item);
                    }
                }
                catch (Exception e)
                {
                }
            }

            return(lista2);
        }