From c3193824c4f71854c44c25b702345003e3e5e56e Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Thu, 27 Nov 2025 04:06:32 +0330 Subject: [PATCH] Add ProductsProfile mapping for categories response --- .../Common/Mappings/ProductsProfile.cs | 27 +++++++++++++++++++ .../BackOffice.BFF.Products.Protobuf.csproj | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/BackOffice.BFF.WebApi/Common/Mappings/ProductsProfile.cs diff --git a/src/BackOffice.BFF.WebApi/Common/Mappings/ProductsProfile.cs b/src/BackOffice.BFF.WebApi/Common/Mappings/ProductsProfile.cs new file mode 100644 index 0000000..f0312dc --- /dev/null +++ b/src/BackOffice.BFF.WebApi/Common/Mappings/ProductsProfile.cs @@ -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() + .MapWith(src => new GetCategoriesResponse + { + Items = + { + (src.Items ?? Enumerable.Empty()) + .Select(x => new CategoryItem + { + Id = x.Id, + Title = x.Title ?? string.Empty, + Selected = x.Selected + }) + } + }); + } +} + diff --git a/src/Protobufs/BackOffice.BFF.Products.Protobuf/BackOffice.BFF.Products.Protobuf.csproj b/src/Protobufs/BackOffice.BFF.Products.Protobuf/BackOffice.BFF.Products.Protobuf.csproj index 86395ca..1c097e5 100644 --- a/src/Protobufs/BackOffice.BFF.Products.Protobuf/BackOffice.BFF.Products.Protobuf.csproj +++ b/src/Protobufs/BackOffice.BFF.Products.Protobuf/BackOffice.BFF.Products.Protobuf.csproj @@ -4,7 +4,7 @@ net9.0 enable enable - 0.0.2 + 0.0.3 None False False