Skip to content

Commit 87eea0f

Browse files
feat: Add base Database, Client (#2)
1 parent c181e49 commit 87eea0f

40 files changed

Lines changed: 1816 additions & 46 deletions

Directory.Packages.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.6" />
8+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.6" />
9+
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
10+
<PackageVersion Include="Spectre.Console" Version="0.49.1" />
11+
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.1.7" />
812
</ItemGroup>
913
</Project>

docker-compose.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
services:
2+
postgres:
3+
image: postgres:18.3-alpine
4+
restart: always
5+
shm_size: 128mb
6+
volumes:
7+
- postgres-data:/var/lib/postgresql/18/docker
8+
ports:
9+
- "25432:5432"
10+
environment:
11+
POSTGRES_PASSWORD: example
12+
13+
volumes:
14+
postgres-data:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Text.Json.Serialization;
2+
using AspNetCoreExampleProject.Api.Requests.City;
3+
using AspNetCoreExampleProject.Api.Requests.Person;
4+
using AspNetCoreExampleProject.Api.Responses.City;
5+
using AspNetCoreExampleProject.Api.Responses.Health;
6+
using AspNetCoreExampleProject.Api.Responses.Person;
7+
8+
namespace AspNetCoreExampleProject.Api;
9+
10+
// Requests
11+
[JsonSerializable(typeof(CreateCityRequest))]
12+
[JsonSerializable(typeof(CreatePersonRequest))]
13+
[JsonSerializable(typeof(AddFriendRequest))]
14+
[JsonSerializable(typeof(RemoveFriendRequest))]
15+
// Responses
16+
[JsonSerializable(typeof(CityDetailResponse))]
17+
[JsonSerializable(typeof(CityMinimalResponse))]
18+
[JsonSerializable(typeof(PersonDetailResponse))]
19+
[JsonSerializable(typeof(PersonMinimalResponse))]
20+
[JsonSerializable(typeof(CityListResponse))]
21+
[JsonSerializable(typeof(PersonListResponse))]
22+
[JsonSerializable(typeof(HealthCheckResponse))]
23+
// Setup
24+
[JsonSourceGenerationOptions(
25+
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
26+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
27+
)]
28+
public sealed partial class AspNetCoreExampleProjectJsonContext : JsonSerializerContext;

src/AspNetCoreExampleProject.Api/Class1.cs

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace AspNetCoreExampleProject.Api.Requests.City;
2+
3+
public class CreateCityRequest
4+
{
5+
public required string Name { get; set; }
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace AspNetCoreExampleProject.Api.Requests.Person;
2+
3+
public class AddFriendRequest
4+
{
5+
public int FirstPersonId { get; set; }
6+
public int SecondPersonId { get; set; }
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace AspNetCoreExampleProject.Api.Requests.Person;
2+
3+
public class CreatePersonRequest
4+
{
5+
public required string FirstName { get; set; }
6+
public required string LastName { get; set; }
7+
8+
public int CityId { get; set; }
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace AspNetCoreExampleProject.Api.Requests.Person;
2+
3+
public class RemoveFriendRequest
4+
{
5+
public int FirstPersonId { get; set; }
6+
7+
public int SecondPersonId { get; set; }
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using AspNetCoreExampleProject.Api.Responses.Person;
2+
3+
namespace AspNetCoreExampleProject.Api.Responses.City;
4+
5+
public class CityDetailResponse : CityMinimalResponse
6+
{
7+
public ICollection<PersonMinimalResponse> Persons { get; set; } = [];
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace AspNetCoreExampleProject.Api.Responses.City;
2+
3+
public class CityListResponse
4+
{
5+
public List<CityMinimalResponse> Cities { get; set; } = [];
6+
}

0 commit comments

Comments
 (0)