Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created July 22, 2019 10:32
Show Gist options
  • Save ntakouris/0c323cfbce766c7bf169c218500cbe16 to your computer and use it in GitHub Desktop.
Save ntakouris/0c323cfbce766c7bf169c218500cbe16 to your computer and use it in GitHub Desktop.
public async Task<bool> UserOwnsPostAsync(Guid postId, string userId)
{
var post = await _dataContext.Posts.AsNoTracking().SingleOrDefaultAsync(x => x.Id == postId);
if (post == null)
{
return false;
}
if (post.UserId != userId)
{
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment