Exemplo n.º 1
0
        public IActionResult Index(string userId)
        {
            if (this.userManager.GetUserId(User) == userId)
            {
                return(RedirectToAction("MyProfile", "Account"));
            }

            var currentUserId = this.userManager.GetUserId(User);

            var viewModel = new PostsFeedAndUserInfoViewModel()
            {
                CurrentUserInfo = userServices.GetUserInfo(currentUserId, currentUserId),
                Posts           = postServices.GetUserPosts(userId, currentUserId, 0),
                UserProfileInfo = userServices.GetUserInfo(userId, currentUserId),
            };

            if (viewModel.UserProfileInfo == null || viewModel.CurrentUserInfo == null)
            {
                var result = this.View("Error", this.ModelState);
                ViewData["Message"] = ErrorConstants.PageNotAvaivableMessage;
                result.StatusCode   = (int)HttpStatusCode.NotFound;
                return(result);
            }

            return(this.View(viewModel));
        }
        public IActionResult MyProfile(MyProfileViewModel inputModel)
        {
            var userId          = this.userManager.GetUserId(User);
            var whoToFollowList = new UsersListViewModel()
            {
                Users      = followersServices.GetUsersToFollow(User).ToList(),
                UsersCount = ControllerConstants.WhoToFollowPartialFollowerCount,
            };
            var viewModel = new MyProfileViewModel
            {
                CurrentUserInfo       = userServices.GetUserInfo(userId, userId),
                Posts                 = postServices.GetUserPosts(userId, userId, 0),
                IsValidProfilePicture = inputModel.IsValidProfilePicture,
                UserProfileInfo       = userServices.GetUserInfo(userId, userId),
                WhoToFollow           = whoToFollowList
            };

            return(View(viewModel));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> MyProfile(MyProfileViewModel inputModel)
        {
            var userId          = this.userServices.GetUserId(User);
            var whoToFollowList = new UsersListViewModel()
            {
                Users      = await followersServices.GetUsersToFollow(User),
                UsersCount = ControllerConstants.WhoToFollowPartialFollowerCount,
            };

            //TODO: Fix the whole logic behind this method because - dont user GetUserInfo
            var viewModel = new MyProfileViewModel
            {
                CurrentUserInfo       = await userServices.GetUserInfo(userId, userId),
                Posts                 = postServices.GetUserPosts(userId, userId, 0),
                IsValidProfilePicture = inputModel.IsValidProfilePicture,
                UserProfileInfo       = await userServices.GetUserInfo(userId, userId),
                WhoToFollow           = whoToFollowList
            };

            return(View(viewModel));
        }