public HttpResponseMessage PostReaction(string tweetKey, string reactionKey) { var userToken = HttpContext.Current.User.Identity.Name; var userEmail = TokenManager.GetEmailFromToken(userToken); var user = _userManager.GetUserByEmail(userEmail); if (user != null) { Guid guidTweetKey = new Guid(tweetKey); Guid guidReactionkey = new Guid(reactionKey); var tweet = _tweetManager.GetTweet(guidTweetKey); if (tweet == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } var reaction = _reactionManager.GetReaction(guidReactionkey); if (reaction == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } if (_reactionManager.AddReaction(user, tweet, reaction)) { return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); } return(Request.CreateResponse(HttpStatusCode.Unauthorized)); }
public HttpResponseMessage GetTweet(string key) { var tweetKey = new Guid(key); var tweet = _tweetManager.GetTweet(tweetKey); if (tweet != null) { return(Request.CreateResponse(HttpStatusCode.OK, tweet.ToTweetDto())); } return(Request.CreateResponse(HttpStatusCode.NotFound)); }