Add category products query and update endpoints

This commit is contained in:
masoodafar-web
2025-11-27 04:58:09 +03:30
parent bb8d35a1d1
commit 8878c07031
9 changed files with 242 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
namespace BackOffice.BFF.WebApi.Common.Mappings;
using BackOffice.BFF.Application.ProductsCQ.Queries.GetCategories;
using BackOffice.BFF.Application.ProductsCQ.Queries.GetProductsForCategory;
using BackOffice.BFF.Application.ProductsCQ.Queries.GetProductGallery;
using BackOffice.BFF.Products.Protobuf.Protos.Products;
public class ProductsProfile : IRegister
@@ -22,6 +24,39 @@ public class ProductsProfile : IRegister
})
}
});
// Map GetProductsForCategory response DTO to protobuf response
config.NewConfig<GetProductsForCategoryResponseDto, GetProductsForCategoryResponse>()
.MapWith(src => new GetProductsForCategoryResponse
{
Items =
{
(src.Items ?? Enumerable.Empty<CategoryProductItemDto>())
.Select(x => new CategoryProductItem
{
Id = x.Id,
Title = x.Title ?? string.Empty,
Selected = x.Selected
})
}
});
// Map GetProductGallery response DTO to protobuf response
config.NewConfig<GetProductGalleryResponseDto, GetProductGalleryResponse>()
.MapWith(src => new GetProductGalleryResponse
{
Items =
{
(src.Items ?? Enumerable.Empty<ProductGalleryItemDto>())
.Select(x => new ProductGalleryItem
{
ProductGalleryId = x.ProductGalleryId,
ProductImageId = x.ProductImageId,
Title = x.Title ?? string.Empty,
ImagePath = x.ImagePath ?? string.Empty,
ImageThumbnailPath = x.ImageThumbnailPath ?? string.Empty
})
}
});
}
}