Пример #1
0
        public IList <GetTweetDto> GetAllTweet(int userId)
        {
            GetTweetDto tweet;

            getTweets = new GetTweets();
            tweetList = new List <TweetDto>();
            IList <GetTweetDto> allTweets = new List <GetTweetDto>();

            tweetList = getTweets.GetAllTweets(userId);
            foreach (var i in tweetList)
            {
                tweet               = new GetTweetDto();
                tweet.id            = i.id;
                tweet.Body          = i.Body;
                tweet.User_id       = i.User_id;
                tweet.User_name     = i.User_name;
                tweet.Like_count    = i.Like_count;
                tweet.dislike_count = i.dislike_count;
                tweet.Created_at    = i.Created_at.ToShortDateString().ToString();
                if (i.reaction == true)
                {
                    tweet.reaction = "Liked";
                }
                else if (i.reaction == false)
                {
                    tweet.reaction = "Disliked";
                }
                else
                {
                    tweet.reaction = "not reacted";
                }

                allTweets.Add(tweet);
            }

            // tweetList.Sort((obj1, obj2) => DateTime.Compare(obj2.CreatedAt, obj1.CreatedAt));
            //tweetList.OrderByDescending(f => f.id);
            IList <GetTweetDto> x = allTweets.OrderByDescending(i => i.id).ToList();

            return(x);
        }
Пример #2
0
        /// <summary>
        /// Searches the tweet.
        /// </summary>
        /// <param name="tag">The tag.</param>
        /// <returns></returns>
        public IList <GetTweetDto> SearchTweet(string tag)
        {
            getTweet = new GetTweets();
            GetTweetDto         tweet;
            IList <GetTweetDto> allTweets     = new List <GetTweetDto>();
            IList <TweetDto>    searchedtweet = getTweet.GetTagTweet(tag);

            if (searchedtweet == null)
            {
                return(null);
            }
            foreach (var i in searchedtweet)
            {
                tweet               = new GetTweetDto();
                tweet.id            = i.id;
                tweet.Body          = i.Body;
                tweet.User_id       = i.User_id;
                tweet.User_name     = i.User_name;
                tweet.Like_count    = i.Like_count;
                tweet.dislike_count = i.dislike_count;
                tweet.Created_at    = i.Created_at.ToShortDateString().ToString();
                if (i.reaction == true)
                {
                    tweet.reaction = "Liked";
                }
                else if (i.reaction == false)
                {
                    tweet.reaction = "Disliked";
                }
                else
                {
                    tweet.reaction = "not reacted";
                }

                allTweets.Add(tweet);
            }
            return(allTweets);
        }