Exemplo n.º 1
0
        /*
         * GET /
         */
        public async Task <IActionResult> Index()
        {
            // Get the logged in users UserId.
            string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            // Utilize the userId to get an application user instance of the logged in user.
            ApplicationUser applicationUser = await _userManager.FindByIdAsync(userId);

            // Create an instance of the ViewModel and assign it to a variable.
            var homeViewModel = new HomeViewModel
            {
                User = applicationUser,
                FriendSuggestions = applicationUser.GetTopFiveFriendSuggestions(),
                TimelinePosts     = _timeLine.BuildHomeTimeline(userId)
            };

            return(View(homeViewModel));
        }