47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Webshop.Domain.Entities;
|
|
|
|
/// <summary>
|
|
/// Die einzelnen Artikel innerhalb einer Bestellung.
|
|
/// </summary>
|
|
public class OrderItem
|
|
{
|
|
[Key]
|
|
public Guid Id { get; set; }
|
|
|
|
[Required]
|
|
[ForeignKey(nameof(Order))]
|
|
public Guid OrderId { get; set; }
|
|
|
|
[ForeignKey(nameof(Product))]
|
|
public Guid? ProductId { get; set; }
|
|
|
|
[ForeignKey(nameof(ProductVariant))]
|
|
public Guid? ProductVariantId { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(255)]
|
|
public string ProductName { get; set; } // Snapshot
|
|
|
|
[Required]
|
|
[MaxLength(50)]
|
|
public string ProductSKU { get; set; } // Snapshot
|
|
|
|
[Required]
|
|
public int Quantity { get; set; }
|
|
|
|
// Precision wird via Fluent API konfiguriert
|
|
[Required]
|
|
public decimal UnitPrice { get; set; }
|
|
|
|
[Required]
|
|
public decimal TotalPrice { get; set; }
|
|
|
|
// Navigation Properties
|
|
public virtual Order Order { get; set; }
|
|
public virtual Product? Product { get; set; }
|
|
public virtual ProductVariant? ProductVariant { get; set; }
|
|
} |