categorys
This commit is contained in:
@@ -1,45 +1,51 @@
|
||||
using System;
|
||||
// src/Webshop.Domain/Entities/Category.cs
|
||||
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
|
||||
namespace Webshop.Domain.Entities
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
/// <summary>
|
||||
/// Zum Gruppieren und Organisieren von Produkten.
|
||||
/// </summary>
|
||||
public class Category
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid(); // Hinzufügen von Default-Wert
|
||||
|
||||
[Required]
|
||||
[MaxLength(255)]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
[MaxLength(255)]
|
||||
public string Name { get; set; } = string.Empty; // Hinzufügen von Default-Wert
|
||||
|
||||
[MaxLength(1000)]
|
||||
public string? Description { 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; }
|
||||
[Required]
|
||||
[MaxLength(255)]
|
||||
public string Slug { get; set; } = string.Empty; // Hinzufügen von Default-Wert
|
||||
|
||||
[ForeignKey(nameof(ParentCategory))]
|
||||
public Guid? ParentCategoryId { get; set; }
|
||||
[ForeignKey(nameof(ParentCategory))]
|
||||
public Guid? ParentCategoryId { get; set; }
|
||||
|
||||
[MaxLength(2000)]
|
||||
public string? ImageUrl { get; set; }
|
||||
[MaxLength(2000)]
|
||||
public string? ImageUrl { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool IsActive { get; set; }
|
||||
[Required]
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
[Required]
|
||||
public int DisplayOrder { 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>();
|
||||
// << NEUE EIGENSCHAFTEN HINZUFÜGEN >>
|
||||
public DateTimeOffset CreatedDate { get; set; } = DateTimeOffset.UtcNow;
|
||||
public DateTimeOffset? LastModifiedDate { get; set; }
|
||||
// << ENDE NEUE EIGENSCHAFTEN >>
|
||||
|
||||
// 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>();
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
// Auto-generiert von CreateWebshopFiles.ps1
|
||||
// src/Webshop.Domain/Interfaces/ICategoryRepository.cs
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Webshop.Domain.Entities;
|
||||
|
||||
|
||||
namespace Webshop.Domain.Interfaces
|
||||
{
|
||||
public interface ICategoryRepository
|
||||
{
|
||||
// Fügen Sie hier Methodensignaturen hinzu
|
||||
Task<IEnumerable<Category>> GetAllAsync();
|
||||
Task<Category?> GetByIdAsync(Guid id);
|
||||
Task<Category?> GetBySlugAsync(string slug);
|
||||
Task AddAsync(Category category);
|
||||
Task UpdateAsync(Category category);
|
||||
Task DeleteAsync(Guid id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user