using Domain.Entities; namespace Features.Breweries.Dtos; /// Maps domain entities to . public static class BreweryDtoMapper { /// /// Converts a to its DTO representation, including its /// if the entity has one. /// 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, Timer = brewery.Timer, Location = 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?.ISO3166_2 ?? string.Empty, CountryName = brewery.Location.City?.StateProvince?.Country?.CountryName ?? string.Empty, CountryCode = brewery.Location.City?.StateProvince?.Country?.ISO3166_1 ?? string.Empty, AddressLine1 = brewery.Location.AddressLine1, AddressLine2 = brewery.Location.AddressLine2, PostalCode = brewery.Location.PostalCode, Coordinates = brewery.Location.Coordinates, }, }; } }