❔ Filter .NET error from beginner

Hii! I'm uising filter from .NET So, I have in the controller
[HttpGet("{pokeId}/rating")]
[ProducesResponseType(200, Type = typeof(decimal))]
[ProducesResponseType(400)]
[PokemonExists]
[ModelStateValid]
public IActionResult GetPokemonRating(int pokeId)
{
var rating = _pokemonRepository.GetPokemonRating(pokeId);

return Ok(rating);
}
[HttpGet("{pokeId}/rating")]
[ProducesResponseType(200, Type = typeof(decimal))]
[ProducesResponseType(400)]
[PokemonExists]
[ModelStateValid]
public IActionResult GetPokemonRating(int pokeId)
{
var rating = _pokemonRepository.GetPokemonRating(pokeId);

return Ok(rating);
}
[PokemonExists]
[ModelStateValid]
[PokemonExists]
[ModelStateValid]
Both are a filter that I make pokemonsExistsAttribute.cs:
No description
6 Replies
peladodocinero
peladodocineroOP14mo ago
ModelValidAttribute.cs:
No description
peladodocinero
peladodocineroOP14mo ago
And I added to program.cs:
No description
peladodocinero
peladodocineroOP14mo ago
So, when I Get Request that's happen:
No description
peladodocinero
peladodocineroOP14mo ago
No description
peladodocinero
peladodocineroOP14mo ago
And another related question. What is the best practice and way to make filters? Because for example, in Node, we made Helper Functions, where we called them to do these kinds of things, like validating roles, checking if a session exists, a model is correct, etc. In .NET is this the best and cleanest option? Thank you
Accord
Accord14mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server