presentation
This commit is contained in:
@@ -12,4 +12,8 @@
|
|||||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Infrastructure\Persistence\Db\Migrations\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ public static class PersistenceRegistrationExtensions
|
|||||||
{
|
{
|
||||||
services.AddDbContext<AipsDbContext>(options =>
|
services.AddDbContext<AipsDbContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseNpgsql(configuration.GetEnvConnectionString());
|
options.UseNpgsql(configuration.GetEnvConnectionString(), npgsql =>
|
||||||
|
{
|
||||||
|
npgsql.MigrationsAssembly(typeof(AipsDbContext).Assembly.FullName);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
|
|||||||
17
dotnet/AipsWebApi/AipsWebApi.csproj
Normal file
17
dotnet/AipsWebApi/AipsWebApi.csproj
Normal file
@@ -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.1"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AipsCore\AipsCore.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
6
dotnet/AipsWebApi/AipsWebApi.http
Normal file
6
dotnet/AipsWebApi/AipsWebApi.http
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
@AipsWebApi_HostAddress = http://localhost:5266
|
||||||
|
|
||||||
|
GET {{AipsWebApi_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
||||||
19
dotnet/AipsWebApi/Controllers/UserController.cs
Normal file
19
dotnet/AipsWebApi/Controllers/UserController.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using AipsCore.Application.Abstract;
|
||||||
|
using AipsCore.Application.Models.User.Command.CreateUser;
|
||||||
|
using AipsCore.Domain.Models.User.ValueObjects;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace AipsWebApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("[controller]")]
|
||||||
|
public class UserController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<int>> CreateUser(CreateUserCommand command, IDispatcher dispatcher, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var userId = await dispatcher.Execute<UserId>(command, cancellationToken);
|
||||||
|
|
||||||
|
return Ok(userId.IdValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
dotnet/AipsWebApi/Controllers/WeatherForecastController.cs
Normal file
25
dotnet/AipsWebApi/Controllers/WeatherForecastController.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace AipsWebApi.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("[controller]")]
|
||||||
|
public class WeatherForecastController : ControllerBase
|
||||||
|
{
|
||||||
|
private static readonly string[] Summaries =
|
||||||
|
[
|
||||||
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||||
|
];
|
||||||
|
|
||||||
|
[HttpGet(Name = "GetWeatherForecast")]
|
||||||
|
public IEnumerable<WeatherForecast> Get()
|
||||||
|
{
|
||||||
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||||
|
{
|
||||||
|
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||||
|
TemperatureC = Random.Shared.Next(-20, 55),
|
||||||
|
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||||
|
})
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
26
dotnet/AipsWebApi/Program.cs
Normal file
26
dotnet/AipsWebApi/Program.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using AipsCore.Infrastructure.DI;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
var configuration = builder.Configuration;
|
||||||
|
|
||||||
|
builder.Services.AddControllers();
|
||||||
|
builder.Services.AddOpenApi();
|
||||||
|
|
||||||
|
builder.Services.AddAips(configuration);
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.MapOpenApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
|
||||||
|
app.Run();
|
||||||
23
dotnet/AipsWebApi/Properties/launchSettings.json
Normal file
23
dotnet/AipsWebApi/Properties/launchSettings.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"applicationUrl": "http://localhost:5266",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": false,
|
||||||
|
"applicationUrl": "https://localhost:7031;http://localhost:5266",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
12
dotnet/AipsWebApi/WeatherForecast.cs
Normal file
12
dotnet/AipsWebApi/WeatherForecast.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace AipsWebApi;
|
||||||
|
|
||||||
|
public class WeatherForecast
|
||||||
|
{
|
||||||
|
public DateOnly Date { get; set; }
|
||||||
|
|
||||||
|
public int TemperatureC { get; set; }
|
||||||
|
|
||||||
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||||
|
|
||||||
|
public string? Summary { get; set; }
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AipsCore", "AipsCore\AipsCore.csproj", "{C2EAA516-A045-4525-9A47-4AA8198FD104}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AipsCore", "AipsCore\AipsCore.csproj", "{C2EAA516-A045-4525-9A47-4AA8198FD104}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AipsWebApi", "AipsWebApi\AipsWebApi.csproj", "{32BC8F43-322F-441A-9AE3-9D0D36B5D22B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -14,5 +16,9 @@ Global
|
|||||||
{C2EAA516-A045-4525-9A47-4AA8198FD104}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{C2EAA516-A045-4525-9A47-4AA8198FD104}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{C2EAA516-A045-4525-9A47-4AA8198FD104}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C2EAA516-A045-4525-9A47-4AA8198FD104}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{C2EAA516-A045-4525-9A47-4AA8198FD104}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C2EAA516-A045-4525-9A47-4AA8198FD104}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{32BC8F43-322F-441A-9AE3-9D0D36B5D22B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{32BC8F43-322F-441A-9AE3-9D0D36B5D22B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{32BC8F43-322F-441A-9AE3-9D0D36B5D22B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{32BC8F43-322F-441A-9AE3-9D0D36B5D22B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user