Created Order, Refund, Shipping
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
namespace LiteCharms.Features.MidrandBooks.Orders.Entities;
|
||||
|
||||
public class ShippingConfiguration : IEntityTypeConfiguration<Shipping>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Shipping> builder)
|
||||
{
|
||||
builder.ToTable("Shippings");
|
||||
|
||||
builder.HasKey(s => s.Id);
|
||||
builder.Property(s => s.OrderId).IsRequired();
|
||||
builder.Property(s => s.AddressId).IsRequired();
|
||||
builder.Property(s => s.ShippingProviderId).IsRequired();
|
||||
builder.Property(s => s.CreatedAt).IsRequired().ValueGeneratedOnAdd().HasDefaultValueSql("now()");
|
||||
builder.Property(s => s.UpdatedAt).HasDefaultValueSql("now()");
|
||||
builder.Property(s => s.Status).IsRequired();
|
||||
|
||||
builder.HasOne(s => s.Order)
|
||||
.WithOne(o => o.Shipping)
|
||||
.HasForeignKey<Shipping>(s => s.OrderId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(s => s.Address)
|
||||
.WithMany()
|
||||
.HasForeignKey(s => s.AddressId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(f => f.ShippingProvider)
|
||||
.WithMany(f => f.Shippings)
|
||||
.HasForeignKey(f => f.ShippingProviderId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user