test bilder upload
Some checks failed
Branch - test - Build and Push Backend API Docker Image / build-and-push (push) Failing after 20s

This commit is contained in:
Tizian.Breuch
2025-11-07 09:49:51 +01:00
parent c078526800
commit 7aa5ec9500
4 changed files with 164 additions and 48 deletions

View File

@@ -16,8 +16,7 @@ namespace Webshop.Domain.Entities
[MaxLength(4000)]
public string? Description { get; set; }
[MaxLength(500)]
public string? ShortDescription { get; set; }
[Required, MaxLength(50)]
public string SKU { get; set; } = string.Empty;
[Required]
public decimal Price { get; set; }
@@ -29,9 +28,7 @@ namespace Webshop.Domain.Entities
[Required]
public int StockQuantity { get; set; }
public decimal? Weight { get; set; }
public decimal? Width { get; set; }
public decimal? Height { get; set; }
public decimal? Length { get; set; }
[Required, MaxLength(255)]
public string Slug { get; set; } = string.Empty;
@@ -53,5 +50,42 @@ namespace Webshop.Domain.Entities
public virtual ICollection<ProductDiscount> ProductDiscounts { get; set; } = new List<ProductDiscount>();
public virtual ICollection<Productcategorie> Productcategories { get; set; } = new List<Productcategorie>();
public virtual ICollection<ProductImage> Images { get; set; } = new List<ProductImage>();
// --- HINZUGEFÜGTE METHODE ZUR AKTUALISIERUNG ---
// Diese Methode kapselt die Logik zur Aktualisierung der Entität aus einem DTO.
// Sie stellt sicher, dass alle relevanten Felder konsistent geändert werden.
public void UpdateFromDto(
string name, string? description, string sku, decimal price, decimal? oldPrice,
bool isActive, int stockQuantity, string slug, decimal? weight,
Guid? supplierId, decimal? purchasePrice, bool isFeatured, int featuredDisplayOrder,
List<Guid> categorieIds)
{
// 1. Einfache Eigenschaften aktualisieren
Name = name;
Description = description;
SKU = sku;
Price = price;
OldPrice = oldPrice;
IsActive = isActive;
StockQuantity = stockQuantity;
IsInStock = stockQuantity > 0; // Abgeleitete Logik
Slug = slug;
Weight = weight;
SupplierId = supplierId;
PurchasePrice = purchasePrice;
IsFeatured = isFeatured;
FeaturedDisplayOrder = featuredDisplayOrder;
LastModifiedDate = DateTimeOffset.UtcNow;
// 2. Kategori-Beziehungen sauber neu aufbauen
Productcategories.Clear();
if (categorieIds != null)
{
foreach (var catId in categorieIds)
{
Productcategories.Add(new Productcategorie { ProductId = this.Id, categorieId = catId });
}
}
}
}
}

View File

@@ -12,7 +12,8 @@ namespace Webshop.Domain.Interfaces
Task<Product?> GetProductByIdAsync(Guid id);
Task<Product?> GetBySlugAsync(string slug);
Task AddProductAsync(Product product);
Task UpdateProductAsync(Product product);
Task<Product?> GetProductByIdForUpdateAsync(Guid id); // NEU
Task UpdateProductAsync(); // GE<47>NDERT (parameterlos)
Task DeleteProductAsync(Guid id);
}
}