This commit is contained in:
2026-10-19 14:19:45 +03:00
parent d430be35cf
commit 259a3a8d2b
24 changed files with 396 additions and 0 deletions
@@ -0,0 +1,7 @@
namespace PokedexApi.Models;
public record Pokemon(int Id, string Name, string Type, int Level);
public record PokemonInput(string Name, string Type, int Level);
public record LevelUpdate(int Level);
+12
View File
@@ -0,0 +1,12 @@
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.Run();
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5014",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7036;http://localhost:5014",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,33 @@
using PokedexApi.Models;
namespace PokedexApi.Storage;
public class PokemonStorage
{
private List<Pokemon> _pokemons = new List<Pokemon>
{
new Pokemon(1, "Pikachu", "Electric", 12),
new Pokemon(2, "Charmander", "Fire", 8),
new Pokemon(3, "Squirtle", "Water", 10)
};
public List<Pokemon> GetAll()
{
return new List<Pokemon>(_pokemons);
}
public Pokemon? GetById(int id)
{
return _pokemons.FirstOrDefault(p => p.Id == id);
}
public List<Pokemon> Filter(string? type, int? level)
{
return _pokemons.Where(p => p.Type == type || p.Level == level).ToList();
}
public List<Pokemon> SearchByName(string query)
{
return _pokemons.Where(p => p.Name.Contains(query)).ToList();
}
public Pokemon Add(PokedexInput)
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
+19
View File
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>lab_02</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11"/>
</ItemGroup>
<ItemGroup>
<Folder Include="Endpoints\" />
<Folder Include="Validation_0.1\" />
</ItemGroup>
</Project>
+6
View File
@@ -0,0 +1,6 @@
@lab_02_HostAddress = http://localhost:5014
GET {{lab_02_HostAddress}}/weatherforecast/
Accept: application/json
###