public async Task <IActionResult> Create([FromBody] Tweet tweet) { if (!User.Identity.IsAuthenticated) { return(StatusCode(StatusCodes.Status401Unauthorized, new ErrorResult { Succeeded = false, Message = "Please login first" })); } if (String.IsNullOrEmpty(tweet.Text)) { return(StatusCode(StatusCodes.Status204NoContent, new ErrorResult { Succeeded = false, Message = "You cannot tweet empty" })); } try { tweet.UserId = User.Identity.Name; var gennum = Task.Run(() => IdGeneraotr()); tweet.TweetId = await gennum; await _tweetService.CreateAsync(tweet); } catch (MyException myex) { return(StatusCode(StatusCodes.Status500InternalServerError, new ErrorResult { Succeeded = false, Message = "Server Error" })); } return(Ok(_mapper.Map <Tweet, TweetDTO>(tweet))); }