Add category products query and update endpoints
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user