Fixed erratic order behavior

This commit is contained in:
lumijiez
2025-06-26 00:16:26 +03:00
parent c21c01c432
commit 266aa529fa
27 changed files with 1381 additions and 1179 deletions

View File

@@ -35,19 +35,12 @@ public class OrderConfiguration : EntityBaseConfiguration<Order>
builder.Property(o => o.ShippingStatusId)
.IsRequired();
builder.Property(o => o.OrderNumber)
.IsRequired()
.HasMaxLength(50);
builder.Property(o => o.Notes)
.HasMaxLength(1000);
builder.Property(o => o.MerchantId)
.HasMaxLength(450);
builder.Property(o => o.ComposingImageUrl)
.HasMaxLength(1000);
builder.Property(o => o.OriginalImageUrls)
.HasConversion(
v => JsonSerializer.Serialize(v, (JsonSerializerOptions?)null),
@@ -55,11 +48,9 @@ public class OrderConfiguration : EntityBaseConfiguration<Order>
.HasColumnType("nvarchar(max)");
builder.Property(o => o.CustomizationImageUrl)
.IsRequired()
.HasMaxLength(1000);
builder.Property(o => o.CustomizationDescription)
.IsRequired()
.HasMaxLength(2000);
builder.HasOne(o => o.OrderStatus)
@@ -80,13 +71,11 @@ public class OrderConfiguration : EntityBaseConfiguration<Order>
builder.HasOne(o => o.User)
.WithMany(u => u.Orders)
.HasForeignKey(o => o.UserId)
.HasPrincipalKey(u => u.Id)
.OnDelete(DeleteBehavior.Restrict);
builder.HasOne<User>()
builder.HasOne(o => o.Merchant)
.WithMany(u => u.MerchantOrders)
.HasForeignKey(o => o.MerchantId)
.HasPrincipalKey(u => u.Id)
.OnDelete(DeleteBehavior.SetNull);
builder.HasOne(o => o.Product)
@@ -102,10 +91,6 @@ public class OrderConfiguration : EntityBaseConfiguration<Order>
builder.HasIndex(o => o.UserId)
.HasDatabaseName("IX_Order_UserId");
builder.HasIndex(o => o.OrderNumber)
.IsUnique()
.HasDatabaseName("IX_Order_OrderNumber");
builder.HasIndex(o => o.OrderDate)
.HasDatabaseName("IX_Order_OrderDate");
@@ -133,4 +118,4 @@ public class OrderConfiguration : EntityBaseConfiguration<Order>
builder.HasIndex(o => new { o.ProductId, o.OrderDate })
.HasDatabaseName("IX_Order_Product_Date");
}
}
}