Пример #1
0
        public async Task <IActionResult> Edit(int id)
        {
            var person     = _author.GetAuthor(id);
            var authResult = await _authService.AuthorizeAsync(User, person, "CanManageAuthor");

            //  var authResult1 = await _authService.AuthorizeAsync(User, person, "CanEditPerson");
            //  var authResult2 = await _authService.AuthorizeAsync(User, person, "ContentEditor");


            if (!authResult.Succeeded)
            {
                return(new ForbidResult());
            }

            var model = _author.GetAuthorForUpdate(id);

            if (model == null)
            {
                _log.LogWarning("Author with Id: {id} found", NotFound());

                return(NotFound()); //Return not found (404 friendly page) if model is null
            }

            return(View(model));
        }