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
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user