예제 #1
0
 public TweetResponseDto PostTweet([FromBody] TweetCreateDto tweetDto)
 {
     _userService.ValidateUser(tweetDto.Credentials);
     return(_mapper.Map <Tweet, TweetResponseDto>(
                _tweetService.CreateTweet(
                    _userService.GetByUsername(tweetDto.Credentials.Username),
                    tweetDto.Content
                    )));
 }
예제 #2
0
        public void shouldPostTweet()
        {
            TweetModel tweetModel = new TweetModel();

            tweetModel.tweetDescription = "This is Test Tweet";
            tweetModel.tweetTag         = "Test";

            var result = _tweetService.CreateTweet(tweetModel);

            Assert.IsTrue(result);
        }
예제 #3
0
        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"));
            }
        }
예제 #4
0
 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"));
 }
예제 #5
0
        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());
        }