public TweetResponseDto PostTweet([FromBody] TweetCreateDto tweetDto) { _userService.ValidateUser(tweetDto.Credentials); return(_mapper.Map <Tweet, TweetResponseDto>( _tweetService.CreateTweet( _userService.GetByUsername(tweetDto.Credentials.Username), tweetDto.Content ))); }
public void shouldPostTweet() { TweetModel tweetModel = new TweetModel(); tweetModel.tweetDescription = "This is Test Tweet"; tweetModel.tweetTag = "Test"; var result = _tweetService.CreateTweet(tweetModel); Assert.IsTrue(result); }
public async Task <ApiResult> CreateTweet(CreateTweetMessage message) { try { var id = User.Claims.First(c => c.Type == ClaimTypes.Name).Value.ToString(); await _tweetService.CreateTweet(id, message.TweetContent); return(ApiResult.Success("Created")); } catch (Exception) { return(ApiResult.BadRequest("Something went wrong")); } }
public JsonResult CreateTweet([FromBody] TweetModel tweet) { try { bool creationStatus = _tweetService.CreateTweet(tweet); if (creationStatus) { return(new JsonResult("Tweet created successfully")); } } catch (Exception ex) { string message = "Meesage : " + ex.Message + " & Stacktrace: " + ex.StackTrace; } return(new JsonResult("Error")); }
public IActionResult CreateTweet([FromBody] TweetData tweetData) { bool status = false; try { status = tweetService.CreateTweet(tweetData); if (status) { return(Ok("Tweet Posted")); } return(Ok("Unable to Post Tweet")); } catch (Exception ex) { this.ExceptionMessage = "Meesage : " + ex.Message + " ,Stacktrace: " + ex.StackTrace; } return(BadRequest()); }