45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace Webshop.Domain.Entities;
|
|
|
|
/// <summary>
|
|
/// Zum Gruppieren und Organisieren von Produkten.
|
|
/// </summary>
|
|
public class Category
|
|
{
|
|
[Key]
|
|
public Guid Id { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(255)]
|
|
public string Name { get; set; }
|
|
|
|
[MaxLength(1000)]
|
|
public string? Description { get; set; }
|
|
|
|
// Unique-Constraint wird typischerweise via Fluent API konfiguriert
|
|
[Required]
|
|
[MaxLength(255)]
|
|
public string Slug { get; set; }
|
|
|
|
[ForeignKey(nameof(ParentCategory))]
|
|
public Guid? ParentCategoryId { get; set; }
|
|
|
|
[MaxLength(2000)]
|
|
public string? ImageUrl { get; set; }
|
|
|
|
[Required]
|
|
public bool IsActive { get; set; }
|
|
|
|
[Required]
|
|
public int DisplayOrder { get; set; }
|
|
|
|
// Navigation Properties
|
|
public virtual Category? ParentCategory { get; set; }
|
|
public virtual ICollection<Category> SubCategories { get; set; } = new List<Category>();
|
|
public virtual ICollection<ProductCategory> ProductCategories { get; set; } = new List<ProductCategory>();
|
|
public virtual ICollection<CategoryDiscount> CategoryDiscounts { get; set; } = new List<CategoryDiscount>();
|
|
} |