Esempio n. 1
0
        public async Task <IActionResult> Personal(string username)
        {
            User thisUser = await userManager.GetUserAsync(HttpContext.User);

            if (thisUser is null)
            {
                throw new System.Exception("In Personal httpContext had no user");
            }
            User profileUser = userManager.Users.FirstOrDefault(u => u.UserName == username);

            if (profileUser is null)
            {
                throw new System.Exception("In Personal, username " + username + " matched no user");
            }
            MyWallViewModel MyWallData = new MyWallViewModel
            {
                ThisUser         = thisUser,
                ProfileUser      = profileUser,
                TopUserInterests = dataRepository.GetTopUsersInterests(profileUser),
                FriendshipStatus = dataRepository.GetFriendship(thisUser, profileUser),
                Posts            = dataRepository.GetAllPostsByUser(profileUser).ToList(),
                Interests        = dataRepository.GetAllInterests().ToList()
            };

            logger.LogInformation("User " + thisUser.UserName + " navigated to " + profileUser.UserName + "'s Page");
            return(View(MyWallData));
        }
Esempio n. 2
0
        public async Task <IActionResult> Index(int id)
        {
            User thisUser = await userManager.GetUserAsync(HttpContext.User);

            if (thisUser is null)
            {
                throw new System.Exception("In index httpContext had no user");
            }
            MyWallViewModel MyWallData = new MyWallViewModel
            {
                ThisUser  = thisUser,
                Posts     = dataRepository.GetAllPostsForUserByInterest(thisUser, id).ToList(),
                Interests = dataRepository.GetAllInterests().ToList()
            };

            logger.LogInformation("User " + thisUser.UserName + " navigated to Home Page");
            return(View(MyWallData));
        }
Esempio n. 3
0
        public async Task <IActionResult> Personal()
        {
            User thisUser = await userManager.GetUserAsync(HttpContext.User);

            if (thisUser is null)
            {
                throw new System.Exception("In Personal httpContext had no user");
            }
            MyWallViewModel MyWallData = new MyWallViewModel
            {
                ThisUser         = thisUser,
                ProfileUser      = thisUser,
                TopUserInterests = dataRepository.GetTopUsersInterests(thisUser),
                Posts            = dataRepository.GetAllPostsByUser(thisUser).ToList(),
                Interests        = dataRepository.GetAllInterests().ToList()
            };

            logger.LogInformation("User " + thisUser.UserName + " navigated to his personal Page");
            return(View(MyWallData));
        }