code quality ?

main
Paul Schneider 2 months ago
parent 1084bb3f3c
commit 5334646c1b
1 changed files with 3 additions and 2 deletions

@ -73,10 +73,11 @@ public class PermissionHandler : IAuthorizationHandler
"/Blogspot/Delete",
StringComparison.OrdinalIgnoreCase))
{
string postId = (string) httpContext.GetRouteValue("id");
string? postId = (string?) httpContext.GetRouteValue("id");
if (long.TryParse(postId, out long id))
{
BlogPost b = applicationDbContext.BlogSpot.FirstOrDefault(b => b.Id == id && b.AuthorId == user.GetUserId());
BlogPost? b = applicationDbContext.BlogSpot.FirstOrDefault
(b => b.Id == id && b.AuthorId == user.GetUserId());
return b != null;
}
}

Loading…