in src/app/ContosoTraders.Api.Core/Services/Implementations/ProductService.cs [101:119]
private ProductDto CustomMapping(Product productDao, IEnumerable<Brand> brands, IEnumerable<Type> types, IEnumerable<Feature> features, bool thumbnailImages = true)
{
var imagesEndpoint = Configuration[KeyVaultConstants.SecretNameImagesEndpoint];
var imagesType = thumbnailImages ? "product-list" : "product-details";
var productDto = new ProductDto
{
Id = productDao.Id,
Name = productDao.Name,
Price = productDao.Price,
ImageUrl = $"{imagesEndpoint}/{imagesType}/{productDao.ImageName}",
Brand = brands?.FirstOrDefault(brand => brand.Id == productDao.BrandId),
Type = types?.FirstOrDefault(type => type.Id == productDao.TypeId),
Features = features?.Where(feature => feature.ProductItemId == productDao.Id).ToList()
};
return productDto;
}