示例#1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bookmark = await _bookmarksManager.Read((int)id);

            if (Bookmark == null)
            {
                return(NotFound());
            }

            return(Page());
        }
示例#2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bookmark = await _bookmarksManager.Read((int)id);

            if (Bookmark == null)
            {
                return(NotFound());
            }
            var currentUserId = Guid.Parse(User.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value);

            if (Bookmark.OwnerId != currentUserId)
            {
                ErrorMessage = "You are not allowed to delete this bookmark.";
                return(RedirectToPage("/Index"));
            }
            return(Page());
        }
示例#3
0
        public IActionResult OnGet(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bookmark = _bookmarksManager.Read((int)id).Result;

            if (Bookmark == null)
            {
                return(NotFound());
            }
            UserList = _userManager.Users.Select(u => new SelectListItem {
                Value = u.Id.ToString(), Text = u.UserName
            }).OrderBy(u => u.Text).ToList();

            return(Page());
        }
示例#4
0
        public IActionResult OnGet(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bookmark = _bookmarksManager.Read((int)id).Result;

            var currentUserId = Guid.Parse(User.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value);

            if (Bookmark.OwnerId != currentUserId)
            {
                ErrorMessage = "You are not allowed to see this bookmark.";
                return(Unauthorized());
            }

            if (Bookmark == null)
            {
                return(NotFound());
            }
            return(Page());
        }