sonderangebot artikel

This commit is contained in:
Tizian.Breuch
2025-08-12 14:32:47 +02:00
parent 3e68caf33c
commit 169c1aa2fd
11 changed files with 85 additions and 11 deletions

View File

@@ -137,6 +137,8 @@ namespace Webshop.Application.Services.Admin
OldPrice = productDto.OldPrice,
SupplierId = productDto.SupplierId,
PurchasePrice = productDto.PurchasePrice,
IsFeatured = productDto.IsFeatured, // << NEU >>
FeaturedDisplayOrder = productDto.FeaturedDisplayOrder, // << NEU >>
Images = images,
Productcategories = productDto.CategorieIds.Select(cId => new Productcategorie { categorieId = cId }).ToList()
};
@@ -196,6 +198,8 @@ namespace Webshop.Application.Services.Admin
existingProduct.SupplierId = productDto.SupplierId;
existingProduct.PurchasePrice = productDto.PurchasePrice;
existingProduct.LastModifiedDate = DateTimeOffset.UtcNow;
existingProduct.IsFeatured = productDto.IsFeatured; // << NEU >>
existingProduct.FeaturedDisplayOrder = productDto.FeaturedDisplayOrder; // << NEU >>
// Kategorien synchronisieren
existingProduct.Productcategories.Clear();

View File

@@ -10,5 +10,6 @@ namespace Webshop.Application.Services.Public.Interfaces
Task<IEnumerable<ProductDto>> GetAllProductsAsync();
Task<ProductDto?> GetProductBySlugAsync(string slug);
Task<IEnumerable<ProductDto>> GetFeaturedProductsAsync(); // << NEU >>
}
}

View File

@@ -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();
}
}
}