예제 #1
0
        public async Task <IActionResult> AddTweet(string tweetContent)
        {
            if (tweetContent == null)
            {
                return(RedirectToAction("Index"));
            }
            string          userId = User.FindFirstValue(ClaimTypes.NameIdentifier); // will give the user's userId
            ApplicationUser user   = await _userManager.Users.Include(u => u.TweetLikes).Include(u => u.Followers).Include(u => u.Following).SingleAsync(u => u.Id == userId);

            Tweet newTweet = new Tweet()
            {
                User    = user,
                Content = tweetContent
            };

            _tweetRepository.PostTweet(newTweet);

            return(RedirectToAction("Index"));
        }