Skip to content
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
fa78a55
создан
Matosik Feb 17, 2026
1ae7749
генерация данных через Bogus
Matosik Mar 11, 2026
6fb6c55
Создан нормальный генератор моделей, который относит модели к их прои…
Matosik Mar 11, 2026
1b19de4
веб сервер
Matosik Mar 12, 2026
f182de1
изменен README под 1 ЛР
Matosik Mar 13, 2026
e82dee3
Вроде всё готово
Matosik Mar 15, 2026
f96b71b
Нормальные логи
Matosik Mar 15, 2026
7af635e
sfdlhkj
Matosik Mar 16, 2026
4de7479
Написаны Unit тесты
Matosik Mar 16, 2026
839686a
Удалены ненужные дерективы using
Matosik Mar 16, 2026
13d2baa
Добавлены описания
Matosik Mar 16, 2026
5170a8d
значение ttl вынесено в appsetting.json
Matosik Mar 17, 2026
0197853
удален ненужный файл
Matosik Mar 17, 2026
990c578
delete string.Empty и добавлены описание описания(даже описания исклю…
Matosik Mar 18, 2026
08d75a0
Удален не используемый класс остался только Dto. Надеюсь это никого н…
Matosik Mar 18, 2026
ab5a2c8
написан primary constructor
Matosik Mar 18, 2026
9a94c4f
Seed => Id
Matosik Mar 18, 2026
975f080
Удалены ненужные закомиченые исключения и один файл = один класс
Matosik Mar 18, 2026
688ed74
лучший способ получать файл с производителями и моделями
Matosik Mar 18, 2026
34c5ec2
Меньше пустых строк
Matosik Mar 18, 2026
b0651bb
VehicleModelGenerator теперь не генератор а просто закрузчик данных д…
Matosik Mar 18, 2026
47f9b8f
JsonSerializerOptions вынесен в статическое поле
Matosik Mar 18, 2026
47fb48c
теперь data не может быть null так как выбросится исключение
Matosik Mar 18, 2026
1c1e4d2
Убрал лишнюю проверку
Matosik Mar 18, 2026
f49ba5e
primary конструктор
Matosik Mar 18, 2026
f1a7125
Удалено то чего быть не должно
Matosik Mar 18, 2026
50be3f3
порт вынесен в appsetting.json
Matosik Mar 18, 2026
d5767dd
primary constructor
Matosik Mar 18, 2026
c6b4c9b
страшная табуляция превратилась в шедевр искусства
Matosik Mar 18, 2026
3fc2ba7
Понижена гарантия валидации данных
Matosik Mar 18, 2026
7ddadc5
вынес адрес клиента в appsetting.json
Matosik Mar 18, 2026
0a0badb
ждем
Matosik Mar 18, 2026
46b43a6
Удален ненужный проект
Matosik Mar 19, 2026
f00be80
Asp => Server
Matosik Mar 19, 2026
850282c
Aspire.StackExchange.Redis.DistributedCaching
Matosik Mar 19, 2026
c1ddc10
cleanup code
Matosik Mar 19, 2026
ccfb2bb
fix
Matosik Mar 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Asp/Asp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="10.0.5" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.5" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Aspire.ServiceDefaults\Aspire.ServiceDefaults.csproj" />
<ProjectReference Include="..\Domain\Domain.csproj" />
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions Asp/Asp.http
Comment thread
danlla marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@Asp_HostAddress = http://localhost:5091

GET {{Asp_HostAddress}}/weatherforecast/
Accept: application/json

###
44 changes: 44 additions & 0 deletions Asp/Controllers/ContractsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Domain.Contracts;
using Domain.Interfaces;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("contracts")]
public class ContractsController : ControllerBase
{
private readonly IVehicleContractCachedService _service;
private ILogger<ContractsController> _logger;


public ContractsController(IVehicleContractCachedService service, ILogger<ContractsController> logger)
{
_service = service;
_logger = logger;
}
Comment thread
danlla marked this conversation as resolved.
Outdated


[HttpGet("vehicle")]
public async Task<ActionResult<VehicleContractDto>> GenerateVehicle([FromQuery] int? seed = null)
Comment thread
danlla marked this conversation as resolved.
Outdated
{
var ip = HttpContext.Connection.RemoteIpAddress?.ToString();
var actualSeed = seed ?? Random.Shared.Next();


_logger.LogInformation(
"Starting generation of vehicle contract. Ip: {IpAddress}, SeedFromQuery: {SeedFromQuery}, ActualSeed: {ActualSeed}",
ip,
seed,
actualSeed);

var contract = await _service.GetVehicleContractAsync(actualSeed);
VehicleContractValidator.Validate(contract);
Comment thread
danlla marked this conversation as resolved.
_logger.LogInformation(
"Vehicle contract generated successfully. Ip: {IpAddress}, Manufacturer: {Manufacturer}, Model: {Model}, Year: {Year}",
ip,
contract.Manufacturer,
contract.Model,
contract.Year);

return Ok(contract);
Comment thread
danlla marked this conversation as resolved.
}
}
60 changes: 60 additions & 0 deletions Asp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Domain.Interfaces;
using Infrastructure.Generators;
using Infrastructure.Services;



var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

// Add services to the container.

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddScoped<IVehicleModelGenerator, VehicleModelGenerator>();
builder.Services.AddScoped<IVehicleContractGenerator, VehicleContractGenerator>();


builder.Services.AddStackExchangeRedisCache(options =>
{
options.Configuration = builder.Configuration.GetConnectionString("cache");
});

builder.Services.AddScoped<IVehicleContractCachedService, VehicleContractCachedService>();


builder.Services.AddCors(options =>
{
options.AddPolicy("ClientPolicy", policy =>
{
policy
.WithOrigins("https://localhost:7282") // адрес клиента
Comment thread
danlla marked this conversation as resolved.
Outdated
.AllowAnyHeader()
.AllowAnyMethod();
});
});


var app = builder.Build();

app.MapDefaultEndpoints();
app.UseCors("ClientPolicy");

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}


app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
41 changes: 41 additions & 0 deletions Asp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:58477",
"sslPort": 44391
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5091",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7087;http://localhost:5091",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
8 changes: 8 additions & 0 deletions Asp/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
12 changes: 12 additions & 0 deletions Asp/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"CacheSettings": {
"VehicleContractExpirationMinutes": 1
}
}
8 changes: 8 additions & 0 deletions Aspire.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var builder = DistributedApplication.CreateBuilder(args);
var redis = builder.AddRedis("cache");
Comment thread
danlla marked this conversation as resolved.
Outdated

builder.AddProject<Projects.Asp>("back")
.WithReference(redis);
Comment thread
danlla marked this conversation as resolved.
Outdated

builder.AddProject<Projects.Client_Wasm>("front");
Comment thread
danlla marked this conversation as resolved.
Outdated
builder.Build().Run();
23 changes: 23 additions & 0 deletions Aspire.AppHost/Aspire.AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>332a680f-f1c5-49c8-a258-12e527af6b5e</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.2" />
<PackageReference Include="Aspire.Hosting.Redis" Version="13.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Asp\Asp.csproj" />
<ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" />
</ItemGroup>

</Project>
29 changes: 29 additions & 0 deletions Aspire.AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17077;http://localhost:15131",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21228",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22147"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15131",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19273",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20035"
}
}
}
}
8 changes: 8 additions & 0 deletions Aspire.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions Aspire.AppHost/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
22 changes: 22 additions & 0 deletions Aspire.ServiceDefaults/Aspire.ServiceDefaults.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />

<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.9.0" />
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.5.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
</ItemGroup>

</Project>
Loading