sonderangebot artikel
This commit is contained in:
@@ -10,5 +10,6 @@ namespace Webshop.Application.Services.Public.Interfaces
|
||||
Task<IEnumerable<ProductDto>> GetAllProductsAsync();
|
||||
|
||||
Task<ProductDto?> GetProductBySlugAsync(string slug);
|
||||
Task<IEnumerable<ProductDto>> GetFeaturedProductsAsync(); // << NEU >>
|
||||
}
|
||||
}
|
||||
@@ -89,5 +89,42 @@ namespace Webshop.Application.Services.Public
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProductDto>> GetFeaturedProductsAsync()
|
||||
{
|
||||
var products = await _context.Products
|
||||
.Where(p => p.IsActive && p.IsFeatured)
|
||||
.OrderBy(p => p.FeaturedDisplayOrder)
|
||||
.Include(p => p.Images)
|
||||
.Include(p => p.Productcategories).ThenInclude(pc => pc.categorie)
|
||||
.ToListAsync();
|
||||
|
||||
return products.Select(p => new ProductDto
|
||||
{
|
||||
Id = p.Id,
|
||||
Name = p.Name,
|
||||
Description = p.ShortDescription, // F<>r die Startseite ist die Kurzbeschreibung ideal
|
||||
SKU = p.SKU,
|
||||
Price = p.Price,
|
||||
IsActive = p.IsActive,
|
||||
IsInStock = p.IsInStock,
|
||||
StockQuantity = p.StockQuantity,
|
||||
Slug = p.Slug,
|
||||
categories = p.Productcategories.Select(pc => new CategorieDto
|
||||
{
|
||||
Id = pc.categorie.Id,
|
||||
Name = pc.categorie.Name,
|
||||
Slug = pc.categorie.Slug
|
||||
}).ToList(),
|
||||
Images = p.Images.OrderBy(i => i.DisplayOrder).Select(img => new ProductImageDto
|
||||
{
|
||||
Id = img.Id,
|
||||
Url = img.Url,
|
||||
IsMainImage = img.IsMainImage,
|
||||
DisplayOrder = img.DisplayOrder
|
||||
}).ToList()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user