4
I want to create a Data Annotation to be able to check in ALL pages of my application if the user who is logging in already has 1 Condomínio
registered, if there is no registered condominium it redirects to the condominium registration screen.
What I have at the moment is this:
protected async Task<ValidationResult> IsValidAsync(ValidationContext validationContext)
{
var userId = await _userManager.GetUserAsync(user);
List<ApplicationCondominium> result = await _condominiumManager.GetCondominiumAsync(userId.Id);
if (result.Count() == 0)
{
return ValidationResult.
}
else
{
return ValidationResult.Success;
}
}
They could help me because I need this validation on all pages of my application.
better create a
filter
ormiddlwerare
if in the core version.– novic
Poderia
explain a little better friend ? yes I am usingcore 2.1
– Matheus
Middleware ASP.NET Core 2.1
– Augusto Vasques