sonderangebot artikel
This commit is contained in:
@@ -16,13 +16,16 @@ namespace Webshop.Application.DTOs.Products
|
||||
public bool IsInStock { get; set; } = true;
|
||||
public int StockQuantity { get; set; }
|
||||
public decimal? Weight { get; set; }
|
||||
// << ENTFERNT: ImageUrl >>
|
||||
public string Slug { get; set; } = string.Empty;
|
||||
public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? LastModifiedDate { get; set; }
|
||||
public Guid? SupplierId { get; set; }
|
||||
public decimal? PurchasePrice { get; set; }
|
||||
public List<Guid> categorieIds { get; set; } = new List<Guid>();
|
||||
public List<ProductImageDto> Images { get; set; } = new List<ProductImageDto>(); // << NEU >>
|
||||
public List<ProductImageDto> Images { get; set; } = new List<ProductImageDto>();
|
||||
|
||||
// << NEU >>
|
||||
public bool IsFeatured { get; set; }
|
||||
public int FeaturedDisplayOrder { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -30,5 +30,8 @@ namespace Webshop.Application.DTOs.Products
|
||||
public decimal? OldPrice { get; set; }
|
||||
public Guid? SupplierId { get; set; }
|
||||
public decimal? PurchasePrice { get; set; }
|
||||
|
||||
public bool IsFeatured { get; set; } = false;
|
||||
public int FeaturedDisplayOrder { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
@@ -33,5 +33,7 @@ namespace Webshop.Application.DTOs.Products
|
||||
public decimal? OldPrice { get; set; }
|
||||
public Guid? SupplierId { get; set; }
|
||||
public decimal? PurchasePrice { get; set; }
|
||||
public bool IsFeatured { get; set; }
|
||||
public int FeaturedDisplayOrder { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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