-
Notifications
You must be signed in to change notification settings - Fork 0
feat(product): T1 — domain entities + DTO (Product, ProductCategory, BaseEntity) #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| namespace Product.Domain.DTOs; | ||
|
|
||
| public class CategoryDto | ||
| { | ||
| public int Id { get; set; } | ||
| public string? Name { get; set; } | ||
| public string? Description { get; set; } | ||
| public string? Icon { get; set; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| namespace Product.Domain.DTOs; | ||
|
|
||
| public class ProductDto | ||
| { | ||
| public int Id { get; set; } | ||
| public string? Name { get; set; } | ||
| public string? Description { get; set; } | ||
| public string? Icon { get; set; } | ||
| public decimal BuyingPrice { get; set; } | ||
| public decimal SellingPrice { get; set; } | ||
| public int UnitsInStock { get; set; } | ||
| public bool IsActive { get; set; } | ||
| public bool IsDiscontinued { get; set; } | ||
| public string? ProductCategoryName { get; set; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Product.Domain.Entities; | ||
|
|
||
| public class BaseEntity | ||
| { | ||
| public int Id { get; set; } | ||
|
|
||
| [MaxLength(40)] | ||
| public string? CreatedBy { get; set; } | ||
|
|
||
| [MaxLength(40)] | ||
| public string? UpdatedBy { get; set; } | ||
|
|
||
| public DateTime UpdatedDate { get; set; } | ||
|
|
||
| public DateTime CreatedDate { get; set; } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| namespace Product.Domain.Entities; | ||
|
|
||
| public class Product : BaseEntity | ||
| { | ||
| public required string Name { get; set; } | ||
| public string? Description { get; set; } | ||
| public string? Icon { get; set; } | ||
| public decimal BuyingPrice { get; set; } | ||
| public decimal SellingPrice { get; set; } | ||
| public int UnitsInStock { get; set; } | ||
| public bool IsActive { get; set; } | ||
| public bool IsDiscontinued { get; set; } | ||
|
|
||
| public int? ParentId { get; set; } | ||
| public Product? Parent { get; set; } | ||
|
|
||
| public int ProductCategoryId { get; set; } | ||
| public required ProductCategory ProductCategory { get; set; } | ||
|
|
||
| public ICollection<Product> Children { get; } = []; | ||
|
Comment on lines
+14
to
+20
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚩 Self-referencing Product relationship needs explicit EF Core configuration The Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged — the self-referencing relationship will need |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| namespace Product.Domain.Entities; | ||
|
|
||
| public class ProductCategory : BaseEntity | ||
| { | ||
| public required string Name { get; set; } | ||
| public string? Description { get; set; } | ||
| public string? Icon { get; set; } | ||
|
|
||
| public ICollection<Product> Products { get; } = []; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 DbContext does not register new entity DbSets
The new
ProductandProductCategoryentities are defined butProductDbContext(src/Services/Product/Product.Infrastructure/Data/ProductDbContext.cs) has noDbSet<>properties for them and no entity configuration inOnModelCreating. EF Core can still discover entities via navigation properties if one is registered, but currently neither is registered. This means any attempt to query or persist these entities will fail untilDbSet<Product>andDbSet<ProductCategory>are added. This is likely intentional scaffolding (the TODO comment inOnModelCreatingsays as much), but it's worth tracking to ensure it doesn't get forgotten.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct —
DbSet<Product>andDbSet<ProductCategory>registration is intentionally out of scope for this domain-only PR. The existing TODO inOnModelCreatingtracks this; it'll be wired up when the Infrastructure layer task lands.