generated from admin/template
lab-01
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user