Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Services/Product/Product.Domain/DTOs/CategoryDto.cs
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; }
}
15 changes: 15 additions & 0 deletions src/Services/Product/Product.Domain/DTOs/ProductDto.cs
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; }
}
Empty file.
18 changes: 18 additions & 0 deletions src/Services/Product/Product.Domain/Entities/BaseEntity.cs
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; }
}
21 changes: 21 additions & 0 deletions src/Services/Product/Product.Domain/Entities/Product.cs

Copy link
Copy Markdown
Contributor Author

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 Product and ProductCategory entities are defined but ProductDbContext (src/Services/Product/Product.Infrastructure/Data/ProductDbContext.cs) has no DbSet<> properties for them and no entity configuration in OnModelCreating. 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 until DbSet<Product> and DbSet<ProductCategory> are added. This is likely intentional scaffolding (the TODO comment in OnModelCreating says as much), but it's worth tracking to ensure it doesn't get forgotten.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct — DbSet<Product> and DbSet<ProductCategory> registration is intentionally out of scope for this domain-only PR. The existing TODO in OnModelCreating tracks this; it'll be wired up when the Infrastructure layer task lands.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Self-referencing Product relationship needs explicit EF Core configuration

The Product entity has a self-referencing parent-child relationship (ParentId/Parent/Children at lines 14-20). EF Core's conventions may handle this, but the cascade delete behavior for self-referencing relationships often requires explicit configuration to avoid cycles (e.g., .OnDelete(DeleteBehavior.Restrict)). Without this, migrations may fail on SQL Server or PostgreSQL depending on provider defaults. The ProductDbContext.OnModelCreating currently has a TODO placeholder, so this should be addressed when that configuration is implemented.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged — the self-referencing relationship will need .OnDelete(DeleteBehavior.Restrict) (or similar) in OnModelCreating. That's Infrastructure-layer work, intentionally deferred to a later task when ProductDbContext configuration is implemented.

}
10 changes: 10 additions & 0 deletions src/Services/Product/Product.Domain/Entities/ProductCategory.cs
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; } = [];
}
Empty file.