public HttpResponseMessage GetTweetsSearched(string key) { var tweets = _tweetManager.SearchTweets(key).OrderByDescending(t => t.CreatedOn).Select(sp => sp.ToTweetDto()); TweetResponseDto tweetsResponseDto = new TweetResponseDto { Tweets = tweets, TweetsCount = tweets.Count() }; return(Request.CreateResponse(HttpStatusCode.OK, tweetsResponseDto)); }
public HttpResponseMessage GetTweetsSearched(string key) { var tweets = _hashtagManager.GetTweetsByHashtag(key).Select(t => t.ToTweetDto()); TweetResponseDto tweetResponseDto = new TweetResponseDto { Tweets = tweets, TweetsCount = tweets.Count() }; return(Request.CreateResponse(HttpStatusCode.OK, tweetResponseDto)); }
public TweetResponseDto Post([FromBody] CreateTweetDto dto) { var tweet = _tweetService.PostTweet(dto); var tweetResponse = new TweetResponseDto(); tweetResponse.Username = tweet.Author.Credentials.Username; tweetResponse.TweetContent = tweet.TweetContent; return(tweetResponse); }
public IEnumerable <TweetResponseDto> Get() { var tweets = _tweetService.GetTweets().ToArray(); var tweetDtos = new TweetResponseDto[tweets.Length]; for (int i = 0; i < tweets.Length; i++) { tweetDtos[i] = new TweetResponseDto(); tweetDtos[i].TweetContent = tweets[i].TweetContent; tweetDtos[i].Username = tweets[i].Author.Credentials.Username; } return(tweetDtos); }
public HttpResponseMessage GetTweets() { var userToken = HttpContext.Current.User.Identity.Name; var userEmail = TokenManager.GetEmailFromToken(userToken); var user = _userManager.GetUserByEmail(userEmail); if (user != null) { var tweets = _tweetManager.GetUserDashboardTweets(user.Key).Select(t => t.ToTweetDto()); TweetResponseDto tweetResponseDto = new TweetResponseDto { Tweets = tweets, TweetsCount = tweets.Count() }; //return Request.CreateResponse(HttpStatusCode.OK, _tweetManager.GetUserDashboardTweets(user.Key).Select(t => t.ToTweetDto())); return(Request.CreateResponse(HttpStatusCode.OK, tweetResponseDto)); //return tweets.ToPaginatedDto(tweets.Select(tw => tw.ToTweetDto())); } return(Request.CreateResponse(HttpStatusCode.Unauthorized)); }