Projektdateien hinzufügen.
This commit is contained in:
86
Webshop.Domain/Entities/Product.cs
Normal file
86
Webshop.Domain/Entities/Product.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Webshop.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 1. Das zentrale Modell für deine Verkaufsartikel.
|
||||
/// </summary>
|
||||
public class Product
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(255)]
|
||||
public string Name { get; set; }
|
||||
|
||||
[MaxLength(4000)]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[MaxLength(500)]
|
||||
public string? ShortDescription { get; set; }
|
||||
|
||||
// Unique-Constraint wird typischerweise via Fluent API konfiguriert:
|
||||
// modelBuilder.Entity<Product>().HasIndex(p => p.SKU).IsUnique();
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string SKU { get; set; }
|
||||
|
||||
// Precision wird typischerweise via Fluent API konfiguriert:
|
||||
// modelBuilder.Entity<Product>().Property(p => p.Price).HasPrecision(18, 2);
|
||||
[Required]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
// modelBuilder.Entity<Product>().Property(p => p.OldPrice).HasPrecision(18, 2);
|
||||
public decimal? OldPrice { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool IsInStock { get; set; }
|
||||
|
||||
[Required]
|
||||
public int StockQuantity { get; set; }
|
||||
|
||||
// modelBuilder.Entity<Product>().Property(p => p.Weight).HasPrecision(18, 3);
|
||||
public decimal? Weight { get; set; }
|
||||
|
||||
// modelBuilder.Entity<Product>().Property(p => p.Width).HasPrecision(18, 2);
|
||||
public decimal? Width { get; set; }
|
||||
|
||||
// modelBuilder.Entity<Product>().Property(p => p.Height).HasPrecision(18, 2);
|
||||
public decimal? Height { get; set; }
|
||||
|
||||
// modelBuilder.Entity<Product>().Property(p => p.Length).HasPrecision(18, 2);
|
||||
public decimal? Length { get; set; }
|
||||
|
||||
[MaxLength(2000)]
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
// Unique-Constraint wird typischerweise via Fluent API konfiguriert:
|
||||
// modelBuilder.Entity<Product>().HasIndex(p => p.Slug).IsUnique();
|
||||
[Required]
|
||||
[MaxLength(255)]
|
||||
public string Slug { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTimeOffset CreatedDate { get; set; }
|
||||
|
||||
public DateTimeOffset? LastModifiedDate { get; set; }
|
||||
|
||||
[ForeignKey(nameof(Supplier))]
|
||||
public Guid? SupplierId { get; set; }
|
||||
|
||||
// modelBuilder.Entity<Product>().Property(p => p.PurchasePrice).HasPrecision(18, 2);
|
||||
public decimal? PurchasePrice { get; set; }
|
||||
|
||||
// Navigation Properties
|
||||
public virtual Supplier? Supplier { get; set; }
|
||||
public virtual ICollection<ProductVariant> Variants { get; set; } = new List<ProductVariant>();
|
||||
public virtual ICollection<Review> Reviews { get; set; } = new List<Review>();
|
||||
public virtual ICollection<ProductDiscount> ProductDiscounts { get; set; } = new List<ProductDiscount>();
|
||||
public virtual ICollection<ProductCategory> ProductCategories { get; set; } = new List<ProductCategory>();
|
||||
}
|
||||
Reference in New Issue
Block a user