Files
components/LiteCharms.Entities/Configuration/ShoppingCartConfiguration.cs
T
Khwezi Mngoma 83f51c6a23 Added notifications
Added shopping cart and items
Added quotes
Refactored relatinoships
Migrated changes
Refactored cqrs commands and queries
Refactored mappings
2026-05-05 23:59:31 +02:00

32 lines
1.2 KiB
C#

namespace LiteCharms.Entities.Configuration;
public class ShoppingCartConfiguration : IEntityTypeConfiguration<ShoppingCart>
{
public void Configure(EntityTypeBuilder<ShoppingCart> builder)
{
builder.ToTable(nameof(ShoppingCart));
builder.HasKey(f => f.Id);
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd();
builder.Property(f => f.UpdatedAt).IsRequired().ValueGeneratedOnAddOrUpdate();
builder.Property(f => f.CustomerId).IsRequired(false);
builder.Property(f => f.OrderId).IsRequired(false);
builder.Property(f => f.QuoteId).IsRequired(false);
builder.HasOne(f => f.Customer)
.WithMany(c => c.ShoppingCarts)
.HasForeignKey(f => f.CustomerId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Order)
.WithOne(o => o.ShoppingCart)
.HasForeignKey<Order>(o => o.ShoppingCartId)
.OnDelete(DeleteBehavior.NoAction);
builder.HasOne(f => f.Quote)
.WithOne(o => o.ShoppingCart)
.HasForeignKey<Quote>(o => o.ShoppingCartId)
.OnDelete(DeleteBehavior.NoAction);
}
}