Created Order, Refund, Shipping

This commit is contained in:
Khwezi Mngoma
2026-05-26 08:24:38 +02:00
parent 20b747e89c
commit 70860efcfb
19 changed files with 320 additions and 11 deletions
@@ -0,0 +1,31 @@
namespace LiteCharms.Features.MidrandBooks.Orders.Entities;
public class OrderItemConfiguration : IEntityTypeConfiguration<OrderItem>
{
public void Configure(EntityTypeBuilder<OrderItem> builder)
{
builder.ToTable("OrderItems");
builder.HasKey(oi => oi.Id);
builder.Property(oi => oi.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("new()");
builder.Property(oi => oi.OrderId).IsRequired();
builder.Property(oi => oi.AuthorBookId).IsRequired();
builder.Property(oi => oi.ProductPriceId).IsRequired();
builder.Property(oi => oi.Quantity).IsRequired();
builder.HasOne(oi => oi.Order)
.WithMany(o => o.OrderItems)
.HasForeignKey(oi => oi.OrderId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne(oi => oi.AuthorBook)
.WithMany()
.HasForeignKey(oi => oi.AuthorBookId)
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne(oi => oi.ProductPrice)
.WithMany()
.HasForeignKey(oi => oi.ProductPriceId)
.OnDelete(DeleteBehavior.Restrict);
}
}