Rebadge the rest of the files

This commit is contained in:
lumijiez
2025-06-03 18:24:40 +03:00
parent 1b6f69fcf9
commit 6a675ac111
77 changed files with 5931 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
using Imprink.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Imprink.Infrastructure.Configuration;
public class EntityBaseConfiguration<T> : IEntityTypeConfiguration<T> where T : EntityBase
{
public virtual void Configure(EntityTypeBuilder<T> builder)
{
builder.HasKey(e => e.Id);
builder.Property(e => e.Id)
.HasDefaultValueSql("NEWID()");
builder.Property(e => e.CreatedAt)
.IsRequired();
builder.Property(e => e.ModifiedAt)
.IsRequired()
.HasDefaultValueSql("GETUTCDATE()");
builder.Property(e => e.CreatedBy)
.IsRequired()
.HasMaxLength(450);
builder.Property(e => e.ModifiedBy)
.IsRequired()
.HasMaxLength(450);
builder.HasIndex(e => e.CreatedAt)
.HasDatabaseName($"IX_{typeof(T).Name}_CreatedAt");
builder.HasIndex(e => e.ModifiedAt)
.HasDatabaseName($"IX_{typeof(T).Name}_ModifiedAt");
builder.HasIndex(e => e.CreatedBy)
.HasDatabaseName($"IX_{typeof(T).Name}_CreatedBy");
}
}

View File

@@ -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");
}
}

View File

@@ -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");
}
}

View File

@@ -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");
}
}

View File

@@ -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" }
);
}
}

View File

@@ -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" }
);
}
}

View File

@@ -0,0 +1,105 @@
using Imprink.Domain.Entities.Product;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Imprink.Infrastructure.Configuration.Products;
public class CategoryConfiguration : EntityBaseConfiguration<Category>
{
public override void Configure(EntityTypeBuilder<Category> builder)
{
base.Configure(builder);
builder.Property(c => c.Name)
.IsRequired()
.HasMaxLength(200);
builder.Property(c => c.Description)
.HasMaxLength(2000);
builder.Property(c => c.ImageUrl)
.HasMaxLength(500);
builder.Property(c => c.SortOrder)
.IsRequired()
.HasDefaultValue(0);
builder.Property(c => c.IsActive)
.IsRequired()
.HasDefaultValue(true);
builder.Property(c => c.ParentCategoryId)
.IsRequired(false);
builder.Property(c => c.CreatedAt)
.IsRequired(false);
builder.Property(c => c.CreatedBy)
.IsRequired(false);
builder.Property(c => c.ModifiedAt)
.IsRequired(false);
builder.Property(c => c.ModifiedBy)
.IsRequired(false);
builder.HasOne(c => c.ParentCategory)
.WithMany(c => c.SubCategories)
.HasForeignKey(c => c.ParentCategoryId)
.OnDelete(DeleteBehavior.Restrict);
builder.HasIndex(c => c.Name)
.HasDatabaseName("IX_Category_Name");
builder.HasIndex(c => c.IsActive)
.HasDatabaseName("IX_Category_IsActive");
builder.HasIndex(c => c.ParentCategoryId)
.HasDatabaseName("IX_Category_ParentCategoryId");
builder.HasIndex(c => new { c.ParentCategoryId, c.SortOrder })
.HasDatabaseName("IX_Category_Parent_SortOrder");
builder.HasIndex(c => new { c.IsActive, c.SortOrder })
.HasDatabaseName("IX_Category_Active_SortOrder");
builder.HasData(
new Category
{
Id = Guid.Parse("11111111-1111-1111-1111-111111111111"),
Name = "Textile",
Description = "Textile and fabric-based products",
IsActive = true,
SortOrder = 1,
CreatedAt = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
ModifiedAt = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
CreatedBy = "system@printbase.com",
ModifiedBy = "system@printbase.com"
},
new Category
{
Id = Guid.Parse("22222222-2222-2222-2222-222222222222"),
Name = "Hard Surfaces",
Description = "Products for hard surface printing",
IsActive = true,
SortOrder = 2,
CreatedAt = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
ModifiedAt = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
CreatedBy = "system@printbase.com",
ModifiedBy = "system@printbase.com"
},
new Category
{
Id = Guid.Parse("33333333-3333-3333-3333-333333333333"),
Name = "Paper",
Description = "Paper-based printing products",
IsActive = true,
SortOrder = 3,
CreatedAt = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
ModifiedAt = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
CreatedBy = "system@printbase.com",
ModifiedBy = "system@printbase.com"
}
);
}
}

View File

@@ -0,0 +1,73 @@
using Imprink.Domain.Entities.Product;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Imprink.Infrastructure.Configuration.Products;
public class ProductConfiguration : EntityBaseConfiguration<Product>
{
public override void Configure(EntityTypeBuilder<Product> builder)
{
base.Configure(builder);
builder.Property(p => p.Name)
.IsRequired()
.HasMaxLength(200);
builder.Property(p => p.Description)
.HasMaxLength(2000);
builder.Property(p => p.BasePrice)
.IsRequired()
.HasColumnType("decimal(18,2)");
builder.Property(p => p.IsCustomizable)
.IsRequired()
.HasDefaultValue(false);
builder.Property(p => p.IsActive)
.IsRequired()
.HasDefaultValue(true);
builder.Property(p => p.ImageUrl)
.HasMaxLength(500);
builder.Property(p => p.CategoryId)
.IsRequired(false);
builder.Property(c => c.CreatedAt)
.IsRequired(false);
builder.Property(c => c.CreatedBy)
.IsRequired(false);
builder.Property(c => c.ModifiedAt)
.IsRequired(false);
builder.Property(c => c.ModifiedBy)
.IsRequired(false);
builder.HasOne(p => p.Category)
.WithMany(c => c.Products)
.HasForeignKey(p => p.CategoryId)
.OnDelete(DeleteBehavior.SetNull);
builder.HasIndex(p => p.Name)
.HasDatabaseName("IX_Product_Name");
builder.HasIndex(p => p.IsActive)
.HasDatabaseName("IX_Product_IsActive");
builder.HasIndex(p => p.IsCustomizable)
.HasDatabaseName("IX_Product_IsCustomizable");
builder.HasIndex(p => p.CategoryId)
.HasDatabaseName("IX_Product_CategoryId");
builder.HasIndex(p => new { p.IsActive, p.IsCustomizable })
.HasDatabaseName("IX_Product_Active_Customizable");
builder.HasIndex(p => new { p.CategoryId, p.IsActive })
.HasDatabaseName("IX_Product_Category_Active");
}
}

View File

@@ -0,0 +1,72 @@
using Imprink.Domain.Entities.Product;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Imprink.Infrastructure.Configuration.Products;
public class ProductVariantConfiguration : EntityBaseConfiguration<ProductVariant>
{
public override void Configure(EntityTypeBuilder<ProductVariant> builder)
{
base.Configure(builder);
builder.Property(pv => pv.ProductId)
.IsRequired();
builder.Property(pv => pv.Size)
.HasMaxLength(50);
builder.Property(pv => pv.Color)
.HasMaxLength(50);
builder.Property(pv => pv.Price)
.IsRequired()
.HasColumnType("decimal(18,2)");
builder.Property(pv => pv.ImageUrl)
.HasMaxLength(500);
builder.Property(pv => pv.Sku)
.IsRequired()
.HasMaxLength(100);
builder.Property(pv => pv.StockQuantity)
.IsRequired()
.HasDefaultValue(0);
builder.Property(pv => pv.IsActive)
.IsRequired()
.HasDefaultValue(true);
builder.Property(c => c.CreatedAt)
.IsRequired(false);
builder.Property(c => c.CreatedBy)
.IsRequired(false);
builder.Property(c => c.ModifiedAt)
.IsRequired(false);
builder.Property(c => c.ModifiedBy)
.IsRequired(false);
builder.HasOne(pv => pv.Product)
.WithMany(p => p.ProductVariants)
.HasForeignKey(pv => pv.ProductId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasIndex(pv => pv.ProductId)
.HasDatabaseName("IX_ProductVariant_ProductId");
builder.HasIndex(pv => pv.Sku)
.IsUnique()
.HasDatabaseName("IX_ProductVariant_SKU");
builder.HasIndex(pv => pv.IsActive)
.HasDatabaseName("IX_ProductVariant_IsActive");
builder.HasIndex(pv => new { pv.ProductId, pv.Size, pv.Color })
.IsUnique()
.HasDatabaseName("IX_ProductVariant_Product_Size_Color");
}
}

View File

@@ -0,0 +1,62 @@
using Imprink.Domain.Entities.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Imprink.Infrastructure.Configuration.Users;
public class AddressConfiguration : EntityBaseConfiguration<Address>
{
public override void Configure(EntityTypeBuilder<Address> builder)
{
base.Configure(builder);
builder.Property(a => a.UserId)
.IsRequired()
.HasMaxLength(450);
builder.Property(a => a.AddressType)
.IsRequired()
.HasMaxLength(50);
builder.Property(a => a.Street)
.IsRequired()
.HasMaxLength(200);
builder.Property(a => a.City)
.IsRequired()
.HasMaxLength(100);
builder.Property(a => a.State)
.HasMaxLength(100);
builder.Property(a => a.PostalCode)
.IsRequired()
.HasMaxLength(20);
builder.Property(a => a.Country)
.IsRequired()
.HasMaxLength(100);
builder.Property(a => a.IsDefault)
.IsRequired()
.HasDefaultValue(false);
builder.Property(a => a.IsActive)
.IsRequired()
.HasDefaultValue(true);
builder.HasOne<ApplicationUser>()
.WithMany(u => u.Addresses)
.HasForeignKey(a => a.UserId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasIndex(a => a.UserId)
.HasDatabaseName("IX_Address_UserId");
builder.HasIndex(a => new { a.UserId, a.AddressType })
.HasDatabaseName("IX_Address_User_Type");
builder.HasIndex(a => new { a.UserId, a.IsDefault })
.HasDatabaseName("IX_Address_User_Default");
}
}

View File

@@ -0,0 +1,66 @@
using Imprink.Domain.Entities.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Imprink.Infrastructure.Configuration.Users;
public class ApplicationRoleConfiguration : IEntityTypeConfiguration<ApplicationRole>
{
public void Configure(EntityTypeBuilder<ApplicationRole> builder)
{
builder.Property(r => r.Description)
.HasMaxLength(500);
builder.Property(r => r.CreatedAt)
.IsRequired()
.HasDefaultValueSql("GETUTCDATE()");
builder.Property(r => r.IsActive)
.IsRequired()
.HasDefaultValue(true);
builder.HasIndex(r => r.IsActive)
.HasDatabaseName("IX_ApplicationRole_IsActive");
var seedDate = new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc);
builder.HasData(
new ApplicationRole
{
Id = "1",
Name = "Administrator",
NormalizedName = "ADMINISTRATOR",
Description = "Full system access",
CreatedAt = seedDate,
IsActive = true
},
new ApplicationRole
{
Id = "2",
Name = "Customer",
NormalizedName = "CUSTOMER",
Description = "Standard customer access",
CreatedAt = seedDate,
IsActive = true
},
new ApplicationRole
{
Id = "3",
Name = "OrderManager",
NormalizedName = "ORDERMANAGER",
Description = "Manage orders and fulfillment",
CreatedAt = seedDate,
IsActive = true
},
new ApplicationRole
{
Id = "4",
Name = "ProductManager",
NormalizedName = "PRODUCTMANAGER",
Description = "Manage products and inventory",
CreatedAt = seedDate,
IsActive = true
}
);
}
}

View File

@@ -0,0 +1,30 @@
using Imprink.Domain.Entities.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Imprink.Infrastructure.Configuration.Users;
public class ApplicationUserConfiguration : IEntityTypeConfiguration<ApplicationUser>
{
public void Configure(EntityTypeBuilder<ApplicationUser> builder)
{
builder.Property(u => u.FirstName)
.HasMaxLength(100);
builder.Property(u => u.LastName)
.HasMaxLength(100);
builder.Property(u => u.ProfileImageUrl)
.HasMaxLength(500);
builder.Property(u => u.CreatedAt)
.IsRequired()
.HasDefaultValueSql("GETUTCDATE()");
builder.Property(u => u.LastLoginAt)
.HasDefaultValueSql("GETUTCDATE()");
builder.Property(u => u.IsActive)
.HasDefaultValue(true);
}
}