Rebadge the rest of the files
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using Imprink.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Imprink.Infrastructure.Configuration.Orders;
|
||||
|
||||
public class OrderAddressConfiguration : EntityBaseConfiguration<OrderAddress>
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<OrderAddress> builder)
|
||||
{
|
||||
base.Configure(builder);
|
||||
|
||||
builder.Property(oa => oa.OrderId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(oa => oa.Street)
|
||||
.IsRequired()
|
||||
.HasMaxLength(200);
|
||||
|
||||
builder.Property(oa => oa.City)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
builder.Property(oa => oa.State)
|
||||
.HasMaxLength(100);
|
||||
|
||||
builder.Property(oa => oa.PostalCode)
|
||||
.IsRequired()
|
||||
.HasMaxLength(20);
|
||||
|
||||
builder.Property(oa => oa.Country)
|
||||
.IsRequired()
|
||||
.HasMaxLength(100);
|
||||
|
||||
builder.HasIndex(oa => oa.OrderId)
|
||||
.IsUnique()
|
||||
.HasDatabaseName("IX_OrderAddress_OrderId");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using Imprink.Domain.Entities.Orders;
|
||||
using Imprink.Domain.Entities.Users;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Imprink.Infrastructure.Configuration.Orders;
|
||||
|
||||
public class OrderConfiguration : EntityBaseConfiguration<Order>
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<Order> builder)
|
||||
{
|
||||
base.Configure(builder);
|
||||
|
||||
builder.Property(o => o.UserId)
|
||||
.IsRequired()
|
||||
.HasMaxLength(450);
|
||||
|
||||
builder.Property(o => o.OrderDate)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(o => o.TotalPrice)
|
||||
.IsRequired()
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
builder.Property(o => o.OrderStatusId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(o => o.ShippingStatusId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(o => o.OrderNumber)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
builder.Property(o => o.Notes)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.HasOne<ApplicationUser>()
|
||||
.WithMany(u => u.Orders)
|
||||
.HasForeignKey(o => o.UserId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(o => o.OrderStatus)
|
||||
.WithMany(os => os.Orders)
|
||||
.HasForeignKey(o => o.OrderStatusId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(o => o.ShippingStatus)
|
||||
.WithMany(ss => ss.Orders)
|
||||
.HasForeignKey(o => o.ShippingStatusId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(o => o.OrderAddress)
|
||||
.WithOne(oa => oa.Order)
|
||||
.HasForeignKey<OrderAddress>(oa => oa.OrderId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
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");
|
||||
|
||||
builder.HasIndex(o => o.OrderStatusId)
|
||||
.HasDatabaseName("IX_Order_OrderStatusId");
|
||||
|
||||
builder.HasIndex(o => o.ShippingStatusId)
|
||||
.HasDatabaseName("IX_Order_ShippingStatusId");
|
||||
|
||||
builder.HasIndex(o => new { o.UserId, o.OrderDate })
|
||||
.HasDatabaseName("IX_Order_User_Date");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using Imprink.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Imprink.Infrastructure.Configuration.Orders;
|
||||
|
||||
public class OrderItemConfiguration : EntityBaseConfiguration<OrderItem>
|
||||
{
|
||||
public override void Configure(EntityTypeBuilder<OrderItem> builder)
|
||||
{
|
||||
base.Configure(builder);
|
||||
|
||||
builder.Property(oi => oi.OrderId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(oi => oi.ProductId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(oi => oi.Quantity)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(1);
|
||||
|
||||
builder.Property(oi => oi.UnitPrice)
|
||||
.IsRequired()
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
builder.Property(oi => oi.TotalPrice)
|
||||
.IsRequired()
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
builder.Property(oi => oi.CustomizationImageUrl)
|
||||
.HasMaxLength(500);
|
||||
|
||||
builder.Property(oi => oi.CustomizationDescription)
|
||||
.HasMaxLength(2000);
|
||||
|
||||
builder.HasOne(oi => oi.Order)
|
||||
.WithMany(o => o.OrderItems)
|
||||
.HasForeignKey(oi => oi.OrderId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.HasOne(oi => oi.Product)
|
||||
.WithMany(p => p.OrderItems)
|
||||
.HasForeignKey(oi => oi.ProductId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasOne(oi => oi.ProductVariant)
|
||||
.WithMany(pv => pv.OrderItems)
|
||||
.HasForeignKey(oi => oi.ProductVariantId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasIndex(oi => oi.OrderId)
|
||||
.HasDatabaseName("IX_OrderItem_OrderId");
|
||||
|
||||
builder.HasIndex(oi => oi.ProductId)
|
||||
.HasDatabaseName("IX_OrderItem_ProductId");
|
||||
|
||||
builder.HasIndex(oi => oi.ProductVariantId)
|
||||
.HasDatabaseName("IX_OrderItem_ProductVariantId");
|
||||
|
||||
builder.HasIndex(oi => new { oi.OrderId, oi.ProductId })
|
||||
.HasDatabaseName("IX_OrderItem_Order_Product");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Imprink.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Imprink.Infrastructure.Configuration.Orders;
|
||||
|
||||
public class OrderStatusConfiguration : IEntityTypeConfiguration<OrderStatus>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<OrderStatus> builder)
|
||||
{
|
||||
builder.HasKey(os => os.Id);
|
||||
|
||||
builder.Property(os => os.Id)
|
||||
.ValueGeneratedNever();
|
||||
|
||||
builder.Property(os => os.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
builder.HasIndex(os => os.Name)
|
||||
.IsUnique()
|
||||
.HasDatabaseName("IX_OrderStatus_Name");
|
||||
|
||||
builder.HasData(
|
||||
new OrderStatus { Id = 0, Name = "Pending" },
|
||||
new OrderStatus { Id = 1, Name = "Processing" },
|
||||
new OrderStatus { Id = 2, Name = "Completed" },
|
||||
new OrderStatus { Id = 3, Name = "Cancelled" }
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Imprink.Domain.Entities.Orders;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Imprink.Infrastructure.Configuration.Orders;
|
||||
|
||||
public class ShippingStatusConfiguration : IEntityTypeConfiguration<ShippingStatus>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<ShippingStatus> builder)
|
||||
{
|
||||
builder.HasKey(ss => ss.Id);
|
||||
|
||||
builder.Property(ss => ss.Id)
|
||||
.ValueGeneratedNever();
|
||||
|
||||
builder.Property(ss => ss.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
builder.HasIndex(ss => ss.Name)
|
||||
.IsUnique()
|
||||
.HasDatabaseName("IX_ShippingStatus_Name");
|
||||
|
||||
builder.HasData(
|
||||
new ShippingStatus { Id = 0, Name = "Prepping" },
|
||||
new ShippingStatus { Id = 1, Name = "Packaging" },
|
||||
new ShippingStatus { Id = 2, Name = "Shipped" },
|
||||
new ShippingStatus { Id = 3, Name = "Delivered" }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user