Example #1
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            Bookmark = await _context.GetBookmarkAsync(id);

            if (Bookmark == null)
            {
                TempData["Message"] = $"Bookmark not found. Id = {id}.";
                return(RedirectToPage("./Index"));
            }

            return(Page());
        }
Example #2
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);

            Bookmark bookmark = await _context.GetBookmarkAsync(id);

            if (ThisUser == null || bookmark == null || !ThisUser.Id.Equals(bookmark.UserId))
            {
                return(RedirectToPage("./Manage"));
            }

            Bookmark = new EditBookmarkModel
            {
                Id          = bookmark.Id,
                Title       = bookmark.Title ?? "",
                Location    = bookmark.Resource.Location,
                Description = bookmark.Description ?? "",
                Tags        = BookmarkTagHelper.ListToString(bookmark.Tags),
                IsPublic    = bookmark.IsPublic,
                Favorited   = bookmark.Favorited
            };

            ReturnPage = Request.Query.ContainsKey("return") ? Request.Query["return"] : "./Manage";

            return(Page());
        }