mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 18:14:44 +00:00
Add BeerStyle entity and related properties; refactor BreweryDto to remove BeerPosts
This commit is contained in:
@@ -24,4 +24,6 @@ public sealed class BeerPost
|
||||
// Navigation Properties
|
||||
public UserAccount? PostedBy { get; set; }
|
||||
public BreweryPost? BrewedBy { get; set; }
|
||||
|
||||
public BeerStyle? BeerStyle { get; set; }
|
||||
}
|
||||
|
||||
16
web/backend/Domain/Domain.Entities/Entities/BeerStyle.cs
Normal file
16
web/backend/Domain/Domain.Entities/Entities/BeerStyle.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace Domain.Entities;
|
||||
|
||||
public sealed class BeerStyle
|
||||
{
|
||||
// PK
|
||||
public Guid BeerStyleId { get; set; } = Guid.Empty;
|
||||
|
||||
// Attributes
|
||||
public string BeerStyleName { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
// Audit Fields
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
public byte[]? RowVersion { get; set; }
|
||||
}
|
||||
@@ -17,40 +17,3 @@ public sealed class City
|
||||
// Navigation Properties
|
||||
public StateProvince? StateProvince { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public sealed class StateProvince
|
||||
{
|
||||
// PK
|
||||
public Guid StateProvinceId { get; set; }
|
||||
|
||||
// FK References
|
||||
public Guid CountryId { get; set; }
|
||||
|
||||
// Attributes
|
||||
public string StateProvinceName { get; set; } = string.Empty;
|
||||
|
||||
// this is the iso 3166-2 code for the state/province, e.g. "CA" for California, "ON" for Ontario, etc.
|
||||
// and is rendered like US-CA for California, CA-ON for Ontario, etc.
|
||||
public string ISO3166_2 { get; set; } = string.Empty;
|
||||
|
||||
// Audit Fields
|
||||
public byte[]? RowVersion { get; set; }
|
||||
|
||||
// Navigation Properties
|
||||
public Country? Country { get; set; }
|
||||
}
|
||||
|
||||
public sealed class Country
|
||||
{
|
||||
// PK
|
||||
public Guid CountryId { get; set; }
|
||||
|
||||
// Attributes
|
||||
public string CountryName { get; set; } = string.Empty;
|
||||
|
||||
public string ISO3166_1 { get; set; } = string.Empty; // this is the iso 3166-1 alpha-2 code for the country, e.g. "US" for United States, "CA" for Canada, etc.
|
||||
|
||||
// Audit Fields
|
||||
public byte[]? RowVersion { get; set; }
|
||||
}
|
||||
|
||||
15
web/backend/Domain/Domain.Entities/Entities/Country.cs
Normal file
15
web/backend/Domain/Domain.Entities/Entities/Country.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Domain.Entities;
|
||||
|
||||
public sealed class Country
|
||||
{
|
||||
// PK
|
||||
public Guid CountryId { get; set; }
|
||||
|
||||
// Attributes
|
||||
public string CountryName { get; set; } = string.Empty;
|
||||
|
||||
public string ISO3166_1 { get; set; } = string.Empty; // this is the iso 3166-1 alpha-2 code for the country, e.g. "US" for United States, "CA" for Canada, etc.
|
||||
|
||||
// Audit Fields
|
||||
public byte[]? RowVersion { get; set; }
|
||||
}
|
||||
23
web/backend/Domain/Domain.Entities/Entities/StateProvince.cs
Normal file
23
web/backend/Domain/Domain.Entities/Entities/StateProvince.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace Domain.Entities;
|
||||
|
||||
public sealed class StateProvince
|
||||
{
|
||||
// PK
|
||||
public Guid StateProvinceId { get; set; }
|
||||
|
||||
// FK References
|
||||
public Guid CountryId { get; set; }
|
||||
|
||||
// Attributes
|
||||
public string StateProvinceName { get; set; } = string.Empty;
|
||||
|
||||
// this is the iso 3166-2 code for the state/province, e.g. "CA" for California, "ON" for Ontario, etc.
|
||||
// and is rendered like US-CA for California, CA-ON for Ontario, etc.
|
||||
public string ISO3166_2 { get; set; } = string.Empty;
|
||||
|
||||
// Audit Fields
|
||||
public byte[]? RowVersion { get; set; }
|
||||
|
||||
// Navigation Properties
|
||||
public Country? Country { get; set; }
|
||||
}
|
||||
20
web/backend/Features/Features.Beers/Features.Beers.csproj
Normal file
20
web/backend/Features/Features.Beers/Features.Beers.csproj
Normal file
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>Features.Breweries</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Domain\Domain.Entities\Domain.Entities.csproj" />
|
||||
<ProjectReference Include="..\..\Domain\Domain.Exceptions\Domain.Exceptions.csproj" />
|
||||
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Sql\Infrastructure.Sql.csproj" />
|
||||
<ProjectReference Include="..\..\Shared\Shared.Contracts\Shared.Contracts.csproj" />
|
||||
<ProjectReference Include="..\..\Shared\Shared.Application\Shared.Application.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -16,8 +16,6 @@ public record BreweryLocationDto(
|
||||
byte[]? Coordinates
|
||||
);
|
||||
|
||||
public record BeerPreviewDto(Guid BeerPostId, string Name, decimal ABV, int IBU);
|
||||
|
||||
/// <summary>A brewery post, as returned by the API.</summary>
|
||||
/// <param name="UpdatedAt">The date and time of the last edit, or <see langword="null"/> if never edited.</param>
|
||||
/// <param name="RowVersion">The row-version/concurrency token used to detect conflicting concurrent updates.</param>
|
||||
@@ -30,6 +28,5 @@ public record BreweryDto(
|
||||
DateTime CreatedAt,
|
||||
DateTime? UpdatedAt,
|
||||
byte[]? RowVersion,
|
||||
BreweryLocationDto? Location,
|
||||
List<BeerPreviewDto> BeerPosts
|
||||
BreweryLocationDto? Location
|
||||
);
|
||||
|
||||
@@ -37,16 +37,7 @@ public static class BreweryDtoMapper
|
||||
AddressLine2: brewery.Location.AddressLine2,
|
||||
PostalCode: brewery.Location.PostalCode,
|
||||
Coordinates: brewery.Location.Coordinates
|
||||
),
|
||||
BeerPosts:
|
||||
[
|
||||
.. brewery.BeerPosts.Select(beer => new BeerPreviewDto(
|
||||
BeerPostId: beer.BeerPostId,
|
||||
Name: beer.Name,
|
||||
ABV: beer.ABV,
|
||||
IBU: beer.IBU
|
||||
)),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user