34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
namespace LiteCharms.Features.TechShop.Quotes.Entities;
|
|
|
|
public class QuoteConfiguration : IEntityTypeConfiguration<Quote>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Quote> builder)
|
|
{
|
|
builder.ToTable("Quotes");
|
|
|
|
builder.HasKey(f => f.Id);
|
|
builder.Property(f => f.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
|
|
builder.Property(f => f.UpdatedAt).IsRequired(false).HasDefaultValueSql(null);
|
|
builder.Property(f => f.ExpiredAt).IsRequired(false).HasDefaultValueSql(null);
|
|
builder.Property(f => f.CustomerId).IsRequired();
|
|
builder.Property(f => f.OrderId);
|
|
builder.Property(f => f.ShoppingCartId);
|
|
builder.Property(f => f.Status).IsRequired().HasConversion<int>();
|
|
builder.Property(f => f.InvoiceUrl).IsRequired(false).HasMaxLength(2048);
|
|
builder.Property(f => f.Reason).IsRequired(false);
|
|
|
|
builder.HasOne(q => q.Customer)
|
|
.WithMany(c => c.Quotes)
|
|
.HasForeignKey(q => q.CustomerId)
|
|
.IsRequired();
|
|
|
|
builder.HasOne(q => q.Order)
|
|
.WithOne(o => o.Quote)
|
|
.HasForeignKey<Quote>(q => q.OrderId);
|
|
|
|
builder.HasOne(q => q.ShoppingCart)
|
|
.WithOne(o => o.Quote)
|
|
.HasForeignKey<Quote>(q => q.ShoppingCartId);
|
|
}
|
|
}
|