Add ProductsProfile mapping for categories response

This commit is contained in:
masoodafar-web
2025-11-27 04:06:32 +03:30
parent 8340a932ce
commit c3193824c4
2 changed files with 28 additions and 1 deletions

View 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
})
}
});
}
}

View File

@@ -4,7 +4,7 @@
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Version>0.0.2</Version> <Version>0.0.3</Version>
<DebugType>None</DebugType> <DebugType>None</DebugType>
<DebugSymbols>False</DebugSymbols> <DebugSymbols>False</DebugSymbols>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild> <GeneratePackageOnBuild>False</GeneratePackageOnBuild>