Good structure so far
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user