generated from admin/template
new
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokedexApi2", "PokedexApi2\PokedexApi2.csproj", "{726EA966-3EC2-4E25-9DC9-5C82383F659B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{726EA966-3EC2-4E25-9DC9-5C82383F659B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,5 @@
|
||||
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);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<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>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Endpoints\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
@PokedexApi2_HostAddress = http://localhost:5189
|
||||
|
||||
GET {{PokedexApi2_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@@ -0,0 +1,15 @@
|
||||
using PokedexApi.Models;
|
||||
|
||||
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:5189",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": false,
|
||||
"applicationUrl": "https://localhost:7085;http://localhost:5189",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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)
|
||||
};
|
||||
|
||||
private readonly object _lock = new object();
|
||||
|
||||
public void DoSomething()
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
// этот блок выполняет только один поток за раз
|
||||
// остальные ждут, пока он выйдет
|
||||
}
|
||||
}
|
||||
new Pokemon(1, "Pikachu", ...)
|
||||
private readonly object _lock = new object();
|
||||
|
||||
// TODO 3: реализуй метод GetAll()
|
||||
// TODO 4: реализуй метод GetById(int id)
|
||||
// TODO 5: реализуй метод Filter(string? type, int? minLevel)
|
||||
if (type != null && p.Type != type) continue;
|
||||
if (minLevel != null && p.Level < minLevel) continue;
|
||||
result.Add(p);
|
||||
// TODO 6: реализуй метод SearchByName(string query)
|
||||
// TODO 7: реализуй метод Add(PokemonInput input)
|
||||
int newId = 1;
|
||||
foreach (var p in _pokemons)
|
||||
{
|
||||
if (p.Id >= newId) newId = p.Id + 1;
|
||||
}
|
||||
new Pokemon(newId, input.Name, input.Type, input.Level)
|
||||
|
||||
// TODO 8: реализуй метод Update(int id, PokemonInput input)
|
||||
// TODO 9: реализуй метод UpdateLevel(int id, int level)
|
||||
// TODO 10: реализуй метод Delete(int id)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace PokedexApi2.Validation;
|
||||
|
||||
public interface PokemonStorage
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user