Add ProductsProfile mapping for categories response
This commit is contained in:
27
src/BackOffice.BFF.WebApi/Common/Mappings/ProductsProfile.cs
Normal file
27
src/BackOffice.BFF.WebApi/Common/Mappings/ProductsProfile.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
namespace BackOffice.BFF.WebApi.Common.Mappings;
|
||||
|
||||
using BackOffice.BFF.Application.ProductsCQ.Queries.GetCategories;
|
||||
using BackOffice.BFF.Products.Protobuf.Protos.Products;
|
||||
|
||||
public class ProductsProfile : IRegister
|
||||
{
|
||||
void IRegister.Register(TypeAdapterConfig config)
|
||||
{
|
||||
// Map GetCategories response DTO (application layer) to protobuf response (BFF products contract)
|
||||
config.NewConfig<GetCategoriesResponseDto, GetCategoriesResponse>()
|
||||
.MapWith(src => new GetCategoriesResponse
|
||||
{
|
||||
Items =
|
||||
{
|
||||
(src.Items ?? Enumerable.Empty<CategoryItemDto>())
|
||||
.Select(x => new CategoryItem
|
||||
{
|
||||
Id = x.Id,
|
||||
Title = x.Title ?? string.Empty,
|
||||
Selected = x.Selected
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>0.0.2</Version>
|
||||
<Version>0.0.3</Version>
|
||||
<DebugType>None</DebugType>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||
|
||||
Reference in New Issue
Block a user