Good structure so far

This commit is contained in:
lumijiez
2025-05-04 23:42:28 +03:00
parent e001ea67a3
commit b466a39e89
22 changed files with 466 additions and 335 deletions

View File

@@ -2,10 +2,13 @@ namespace Printbase.Domain.Entities.Products;
public class Product
{
public Guid Id { get; init; }
public string Name { get; init; } = string.Empty;
public string? Description { get; init; }
public Guid TypeId { get; init; }
public ProductType Type { get; init; } = null!;
public ICollection<ProductVariant> Variants { get; init; } = [];
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public Guid TypeId { get; set; }
public ProductType Type { get; set; } = null!;
public ICollection<ProductVariant> Variants { get; set; } = new List<ProductVariant>();
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool IsActive { get; set; }
}

View File

@@ -5,5 +5,8 @@ public class ProductGroup
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public ICollection<ProductType> Types { get; set; } = [];
public ICollection<ProductType> Types { get; set; } = new List<ProductType>();
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool IsActive { get; set; }
}

View File

@@ -2,10 +2,13 @@ namespace Printbase.Domain.Entities.Products;
public class ProductType
{
public Guid Id { get; init; }
public string Name { get; init; } = string.Empty;
public string? Description { get; init; }
public Guid GroupId { get; init; }
public ProductGroup Group { get; init; } = null!;
public ICollection<Product>? Products { get; init; }
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public Guid GroupId { get; set; }
public ProductGroup Group { get; set; } = null!;
public ICollection<Product> Products { get; set; } = new List<Product>();
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool IsActive { get; set; }
}

View File

@@ -2,12 +2,26 @@ namespace Printbase.Domain.Entities.Products;
public class ProductVariant
{
public Guid Id { get; init; }
public Guid ProductId { get; init; }
public string? Color { get; init; }
public string? Size { get; init; }
public decimal Price { get; init; }
public decimal? Discount { get; init; }
public int Stock { get; init; }
public Product Product { get; init; } = null!;
public Guid Id { get; set; }
public Guid ProductId { get; set; }
public string? Color { get; set; }
public string? Size { get; set; }
public decimal Price { get; set; }
public decimal? Discount { get; set; }
public int Stock { get; set; }
public string? SKU { get; set; }
public Product Product { get; set; } = null!;
public DateTime CreatedAt { get; set; }
public DateTime? UpdatedAt { get; set; }
public bool IsActive { get; set; }
public decimal GetDiscountedPrice()
{
if (Discount is > 0)
{
return Price - Price * Discount.Value / 100m;
}
return Price;
}
}