Update doc comments in Features.Breweries source (#279)

This commit is contained in:
Aaron Po
2026-09-05 14:57:39 -04:00
committed by GitHub
parent 272a25fb05
commit 4aa7ba5d9b
29 changed files with 517 additions and 388 deletions

View File

@@ -2,74 +2,62 @@ using Domain.Entities;
namespace Features.Breweries.Dtos;
/// <summary>Maps <see cref="BreweryPost" /> domain entities to <see cref="BreweryDto" />.</summary>
/// <summary>
/// Converts brewery domain entities into API response models.
/// </summary>
public static class BreweryDtoMapper
{
/// <summary>
/// Converts a <see cref="BreweryPost" /> to its DTO representation, including its
/// <see cref="BreweryDto.Location" /> if the entity has one.
/// Converts a brewery post into its complete API representation.
/// </summary>
public static BreweryDto ToDto(this BreweryPost brewery)
{
return new BreweryDto(
BreweryPostId: brewery.BreweryPostId,
PostedById: brewery.PostedById,
BreweryName: brewery.BreweryName,
Description: brewery.Description,
CreatedAt: brewery.CreatedAt,
UpdatedAt: brewery.UpdatedAt,
RowVersion: brewery.RowVersion,
Location: brewery.Location is null
public static BreweryDto ToDto(this BreweryPost brewery) =>
new(
brewery.BreweryPostId,
brewery.PostedById,
brewery.BreweryName,
brewery.Description,
brewery.CreatedAt,
brewery.UpdatedAt,
brewery.RowVersion,
brewery.Location is null
? null
: new BreweryLocationDto(
BreweryPostLocationId: brewery.Location.BreweryPostLocationId,
CityId: brewery.Location.CityId,
CityName: brewery.Location.City?.CityName ?? string.Empty,
StateProvinceName: brewery.Location.City?.StateProvince?.StateProvinceName
?? string.Empty,
StateProvinceCode: brewery.Location.City?.StateProvince?.Iso31662
?? string.Empty,
CountryName: brewery.Location.City?.StateProvince?.Country?.CountryName
?? string.Empty,
CountryCode: brewery.Location.City?.StateProvince?.Country?.Iso31661
?? string.Empty,
AddressLine1: brewery.Location.AddressLine1,
AddressLine2: brewery.Location.AddressLine2,
PostalCode: brewery.Location.PostalCode,
Coordinates: brewery.Location.Coordinates
brewery.Location.BreweryPostLocationId,
brewery.Location.CityId,
brewery.Location.City?.CityName ?? string.Empty,
brewery.Location.City?.StateProvince?.StateProvinceName ?? string.Empty,
brewery.Location.City?.StateProvince?.Iso31662 ?? string.Empty,
brewery.Location.City?.StateProvince?.Country?.CountryName ?? string.Empty,
brewery.Location.City?.StateProvince?.Country?.Iso31661 ?? string.Empty,
brewery.Location.AddressLine1,
brewery.Location.AddressLine2,
brewery.Location.PostalCode,
brewery.Location.Coordinates
)
);
}
/// <summary>
/// Converts a <see cref="BreweryPost" /> to its simplified DTO representation, used for
/// location-based queries that only need identifying and location details.
/// Converts a brewery post into its location-search representation.
/// </summary>
public static BreweryWithLocationDto ToSimplifiedDto(this BreweryPost brewery)
{
return new BreweryWithLocationDto(
BreweryPostId: brewery.BreweryPostId,
BreweryName: brewery.BreweryName,
Location: brewery.Location is null
public static BreweryWithLocationDto ToSimplifiedDto(this BreweryPost brewery) =>
new(
brewery.BreweryPostId,
brewery.BreweryName,
brewery.Location is null
? null
: new BreweryLocationDto(
BreweryPostLocationId: brewery.Location.BreweryPostLocationId,
CityId: brewery.Location.CityId,
CityName: brewery.Location.City?.CityName ?? string.Empty,
StateProvinceName: brewery.Location.City?.StateProvince?.StateProvinceName
?? string.Empty,
StateProvinceCode: brewery.Location.City?.StateProvince?.Iso31662
?? string.Empty,
CountryName: brewery.Location.City?.StateProvince?.Country?.CountryName
?? string.Empty,
CountryCode: brewery.Location.City?.StateProvince?.Country?.Iso31661
?? string.Empty,
AddressLine1: brewery.Location.AddressLine1,
AddressLine2: brewery.Location.AddressLine2,
PostalCode: brewery.Location.PostalCode,
Coordinates: brewery.Location.Coordinates
brewery.Location.BreweryPostLocationId,
brewery.Location.CityId,
brewery.Location.City?.CityName ?? string.Empty,
brewery.Location.City?.StateProvince?.StateProvinceName ?? string.Empty,
brewery.Location.City?.StateProvince?.Iso31662 ?? string.Empty,
brewery.Location.City?.StateProvince?.Country?.CountryName ?? string.Empty,
brewery.Location.City?.StateProvince?.Country?.Iso31661 ?? string.Empty,
brewery.Location.AddressLine1,
brewery.Location.AddressLine2,
brewery.Location.PostalCode,
brewery.Location.Coordinates
),
DistanceMetres: brewery.Distance?.DistanceMetres
brewery.Distance?.DistanceMetres
);
}
}