This commit is contained in:
2026-10-16 13:27:35 +03:00
parent fcec977971
commit c6fe1ab215
2 changed files with 24 additions and 0 deletions
@@ -75,6 +75,22 @@ app.MapGet("/pokemons/{id}", (int id) =>
}
});
app.MapGet("/pokemons/type/{type}", (string type) =>
{
var filteredPokemons = pokemons
.Where(p => p.Type.Equals(type, StringComparison.OrdinalIgnoreCase))
.ToList();
if (filteredPokemons.Any())
{
return Results.Ok(filteredPokemons);
}
else
{
return Results.NotFound(new { message = $"Покемоны с типом '{type}' не найдены." });
}
});
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();