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
+13
View File
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11"/>
</ItemGroup>
</Project>
+6
View File
@@ -0,0 +1,6 @@
@Pokemon_HostAddress = http://localhost:5288
GET {{Pokemon_HostAddress}}/weatherforecast/
Accept: application/json
###
+41
View File
@@ -0,0 +1,41 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
builder.Services.AddOpenApi();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseHttpsRedirection();
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast");
app.Run();
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5288",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7187;http://localhost:5288",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@@ -0,0 +1,11 @@
using PokedexApi.Models;
namespace PokedexApi.Storage;
public class PokemonStorage
{
public PokemonStorage()
{
}
}
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>Pokemon_0._1</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+7
View File
@@ -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);
+18
View File
@@ -0,0 +1,18 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lab-02", "lab-02\lab-02.csproj", "{693A9649-443F-4CC8-B8BA-EB460AC8D70E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{693A9649-443F-4CC8-B8BA-EB460AC8D70E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
EndGlobal
@@ -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
###