public async Task <IActionResult> View(int id) { var model = _author.GetAuthorDetails(id); if (model == null) { _log.LogWarning("Author with Id: {id} found", NotFound()); return(NotFound()); //Return not found (404 friendly page) if model is null } var author = _author.GetAuthor(id); var iSAuthorized = await _authService.AuthorizeAsync(User, author, "CanManageAuthor"); var authResult = await _authService.AuthorizeAsync(User, author, "IsAdmin"); model.CanManageAuthor = iSAuthorized.Succeeded; model.CanManageAuthor = authResult.Succeeded; _log.LogWarning("User does not have permission to edit author"); return(View(model)); }