Exemple #1
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            string githubId = "";

            foreach (Claim claim in User.Claims)
            {
                if (claim.Type == ClaimTypes.NameIdentifier)
                {
                    githubId = claim.Value;
                }
            }

            ThisUser = await _context.GetUserByGithubId(githubId);

            if (id == 0 || (ThisUser != null && ThisUser.Id == id))
            {
                ViewingUser = ThisUser;
                id          = ThisUser.Id;
                Bookmarks   = await _context.GetBookmarksByUserIdAsync(id);

                FavoriteBookmarks = await _context.GetFavoriteBookmarksByUserIdAsync(id);
            }
            else
            {
                ViewingUser = await _context.GetUserAsync(id);

                Bookmarks = await _context.GetPublicBookmarksByUserIdAsync(id);

                FavoriteBookmarks = await _context.GetPublicFavoriteBookmarksByUserIdAsync(id);
            }

            ClippyMode = (ThisUser != null) ? ThisUser.ClippyMode : false;

            if (ViewingUser == null)
            {
                return(RedirectToPage("/Index"));
            }

            return(Page());
        }