diff --git a/CutList.Web/Data/ApplicationDbContext.cs b/CutList.Web/Data/ApplicationDbContext.cs index 7319a2d..947dffc 100644 --- a/CutList.Web/Data/ApplicationDbContext.cs +++ b/CutList.Web/Data/ApplicationDbContext.cs @@ -12,15 +12,12 @@ public class ApplicationDbContext : DbContext public DbSet Materials => Set(); public DbSet MaterialDimensions => Set(); - public DbSet Suppliers => Set(); public DbSet StockItems => Set(); - public DbSet SupplierOfferings => Set(); public DbSet StockTransactions => Set(); public DbSet CuttingTools => Set(); public DbSet Jobs => Set(); public DbSet JobParts => Set(); public DbSet JobStocks => Set(); - public DbSet PurchaseItems => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -143,15 +140,6 @@ public class ApplicationDbContext : DbContext entity.HasIndex(e => e.NominalSize); }); - // Supplier - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id); - entity.Property(e => e.Name).HasMaxLength(100).IsRequired(); - entity.Property(e => e.ContactInfo).HasMaxLength(500); - entity.Property(e => e.CreatedAt).HasDefaultValueSql("GETUTCDATE()"); - }); - // StockItem modelBuilder.Entity(entity => { @@ -174,7 +162,6 @@ public class ApplicationDbContext : DbContext { entity.HasKey(e => e.Id); entity.Property(e => e.Notes).HasMaxLength(500); - entity.Property(e => e.UnitPrice).HasPrecision(10, 2); entity.Property(e => e.CreatedAt).HasDefaultValueSql("GETUTCDATE()"); entity.HasOne(e => e.StockItem) @@ -186,33 +173,6 @@ public class ApplicationDbContext : DbContext .WithMany() .HasForeignKey(e => e.JobId) .OnDelete(DeleteBehavior.SetNull); - - entity.HasOne(e => e.Supplier) - .WithMany() - .HasForeignKey(e => e.SupplierId) - .OnDelete(DeleteBehavior.SetNull); - }); - - // SupplierOffering - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id); - entity.Property(e => e.PartNumber).HasMaxLength(100); - entity.Property(e => e.SupplierDescription).HasMaxLength(255); - entity.Property(e => e.Price).HasPrecision(10, 2); - entity.Property(e => e.Notes).HasMaxLength(255); - - entity.HasOne(e => e.StockItem) - .WithMany(s => s.SupplierOfferings) - .HasForeignKey(e => e.StockItemId) - .OnDelete(DeleteBehavior.Cascade); - - entity.HasOne(e => e.Supplier) - .WithMany(s => s.Offerings) - .HasForeignKey(e => e.SupplierId) - .OnDelete(DeleteBehavior.Cascade); - - entity.HasIndex(e => new { e.SupplierId, e.StockItemId }).IsUnique(); }); // CuttingTool @@ -282,34 +242,6 @@ public class ApplicationDbContext : DbContext .OnDelete(DeleteBehavior.SetNull); }); - // PurchaseItem - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id); - entity.Property(e => e.Notes).HasMaxLength(500); - entity.Property(e => e.Status) - .HasMaxLength(20) - .HasConversion( - v => v.ToString(), - v => Enum.Parse(v)); - entity.Property(e => e.CreatedAt).HasDefaultValueSql("GETUTCDATE()"); - - entity.HasOne(e => e.StockItem) - .WithMany() - .HasForeignKey(e => e.StockItemId) - .OnDelete(DeleteBehavior.Cascade); - - entity.HasOne(e => e.Supplier) - .WithMany() - .HasForeignKey(e => e.SupplierId) - .OnDelete(DeleteBehavior.SetNull); - - entity.HasOne(e => e.Job) - .WithMany() - .HasForeignKey(e => e.JobId) - .OnDelete(DeleteBehavior.SetNull); - }); - // Seed default cutting tools modelBuilder.Entity().HasData( new CuttingTool { Id = 1, Name = "Bandsaw", KerfInches = 0.0625m, IsDefault = true, IsActive = true }, diff --git a/CutList.Web/Data/Entities/PurchaseItem.cs b/CutList.Web/Data/Entities/PurchaseItem.cs deleted file mode 100644 index f737b09..0000000 --- a/CutList.Web/Data/Entities/PurchaseItem.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace CutList.Web.Data.Entities; - -public enum PurchaseItemStatus -{ - Pending, - Ordered, - Received -} - -public class PurchaseItem -{ - public int Id { get; set; } - public int StockItemId { get; set; } - public int? SupplierId { get; set; } - public int Quantity { get; set; } - public int? JobId { get; set; } - public string? Notes { get; set; } - public PurchaseItemStatus Status { get; set; } = PurchaseItemStatus.Pending; - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; - public DateTime? UpdatedAt { get; set; } - - public StockItem StockItem { get; set; } = null!; - public Supplier? Supplier { get; set; } - public Job? Job { get; set; } -} diff --git a/CutList.Web/Data/Entities/StockItem.cs b/CutList.Web/Data/Entities/StockItem.cs index 6aeba92..293054c 100644 --- a/CutList.Web/Data/Entities/StockItem.cs +++ b/CutList.Web/Data/Entities/StockItem.cs @@ -13,6 +13,5 @@ public class StockItem public DateTime? UpdatedAt { get; set; } public Material Material { get; set; } = null!; - public ICollection SupplierOfferings { get; set; } = new List(); public ICollection Transactions { get; set; } = new List(); } diff --git a/CutList.Web/Data/Entities/StockTransaction.cs b/CutList.Web/Data/Entities/StockTransaction.cs index 1dc6839..176583c 100644 --- a/CutList.Web/Data/Entities/StockTransaction.cs +++ b/CutList.Web/Data/Entities/StockTransaction.cs @@ -7,14 +7,11 @@ public class StockTransaction public int Quantity { get; set; } public StockTransactionType Type { get; set; } public int? JobId { get; set; } - public int? SupplierId { get; set; } - public decimal? UnitPrice { get; set; } public string? Notes { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; public StockItem StockItem { get; set; } = null!; public Job? Job { get; set; } - public Supplier? Supplier { get; set; } } public enum StockTransactionType diff --git a/CutList.Web/Data/Entities/Supplier.cs b/CutList.Web/Data/Entities/Supplier.cs deleted file mode 100644 index 2bcbdcd..0000000 --- a/CutList.Web/Data/Entities/Supplier.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CutList.Web.Data.Entities; - -public class Supplier -{ - public int Id { get; set; } - public string Name { get; set; } = string.Empty; - public string? ContactInfo { get; set; } - public string? Notes { get; set; } - public bool IsActive { get; set; } = true; - public DateTime CreatedAt { get; set; } = DateTime.UtcNow; - - public ICollection Offerings { get; set; } = new List(); -} diff --git a/CutList.Web/Data/Entities/SupplierOffering.cs b/CutList.Web/Data/Entities/SupplierOffering.cs deleted file mode 100644 index f85ff55..0000000 --- a/CutList.Web/Data/Entities/SupplierOffering.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CutList.Web.Data.Entities; - -public class SupplierOffering -{ - public int Id { get; set; } - public int StockItemId { get; set; } - public int SupplierId { get; set; } - public string? PartNumber { get; set; } - public string? SupplierDescription { get; set; } - public decimal? Price { get; set; } - public string? Notes { get; set; } - public bool IsActive { get; set; } = true; - - public StockItem StockItem { get; set; } = null!; - public Supplier Supplier { get; set; } = null!; -} diff --git a/CutList.Web/Migrations/20260801124832_RemoveVendorData.Designer.cs b/CutList.Web/Migrations/20260801124832_RemoveVendorData.Designer.cs new file mode 100644 index 0000000..77e1879 --- /dev/null +++ b/CutList.Web/Migrations/20260801124832_RemoveVendorData.Designer.cs @@ -0,0 +1,684 @@ +// +using System; +using CutList.Web.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CutList.Web.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20260801124832_RemoveVendorData")] + partial class RemoveVendorData + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.HasSequence("MaterialDimensionsSequence"); + + modelBuilder.Entity("CutList.Web.Data.Entities.CuttingTool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("KerfInches") + .HasPrecision(6, 4) + .HasColumnType("decimal(6,4)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("CuttingTools"); + + b.HasData( + new + { + Id = 1, + IsActive = true, + IsDefault = true, + KerfInches = 0.0625m, + Name = "Bandsaw" + }, + new + { + Id = 2, + IsActive = true, + IsDefault = false, + KerfInches = 0.125m, + Name = "Chop Saw" + }, + new + { + Id = 3, + IsActive = true, + IsDefault = false, + KerfInches = 0.0625m, + Name = "Cold Cut Saw" + }, + new + { + Id = 4, + IsActive = true, + IsDefault = false, + KerfInches = 0.0625m, + Name = "Hacksaw" + }); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); + + b.Property("Customer") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CuttingToolId") + .HasColumnType("int"); + + b.Property("JobNumber") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LockedAt") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("OptimizationResultJson") + .HasColumnType("nvarchar(max)"); + + b.Property("OptimizedAt") + .HasColumnType("datetime2"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CuttingToolId"); + + b.HasIndex("JobNumber") + .IsUnique(); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.JobPart", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("JobId") + .HasColumnType("int"); + + b.Property("LengthInches") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("JobId"); + + b.HasIndex("MaterialId"); + + b.ToTable("JobParts"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.JobStock", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("IsCustomLength") + .HasColumnType("bit"); + + b.Property("JobId") + .HasColumnType("int"); + + b.Property("LengthInches") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.Property("Priority") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("StockItemId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("JobId"); + + b.HasIndex("MaterialId"); + + b.HasIndex("StockItemId"); + + b.ToTable("JobStocks"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.Material", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); + + b.Property("Description") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Grade") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("Shape") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Size") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("SortOrder") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Materials"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.MaterialDimensions", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasDefaultValueSql("NEXT VALUE FOR [MaterialDimensionsSequence]"); + + SqlServerPropertyBuilderExtensions.UseSequence(b.Property("Id")); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MaterialId") + .IsUnique(); + + b.ToTable((string)null); + + b.UseTpcMappingStrategy(); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("LengthInches") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Notes") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("QuantityOnHand") + .HasColumnType("int"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("MaterialId", "LengthInches") + .IsUnique(); + + b.ToTable("StockItems"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.StockTransaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); + + b.Property("JobId") + .HasColumnType("int"); + + b.Property("Notes") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("StockItemId") + .HasColumnType("int"); + + b.Property("Type") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("JobId"); + + b.HasIndex("StockItemId"); + + b.ToTable("StockTransactions"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.AngleDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Leg1") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Leg2") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Thickness") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Leg1"); + + b.ToTable("DimAngle", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.ChannelDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Flange") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Height") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Web") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Height"); + + b.ToTable("DimChannel", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.FlatBarDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Thickness") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Width") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Width"); + + b.ToTable("DimFlatBar", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.IBeamDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Height") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("WeightPerFoot") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Height"); + + b.ToTable("DimIBeam", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.PipeDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("NominalSize") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Schedule") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Wall") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("NominalSize"); + + b.ToTable("DimPipe", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.RectangularTubeDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Height") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Wall") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Width") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Width"); + + b.ToTable("DimRectangularTube", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.RoundBarDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Diameter") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Diameter"); + + b.ToTable("DimRoundBar", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.RoundTubeDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("OuterDiameter") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Wall") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("OuterDiameter"); + + b.ToTable("DimRoundTube", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.SquareBarDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Size") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Size"); + + b.ToTable("DimSquareBar", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.SquareTubeDimensions", b => + { + b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); + + b.Property("Size") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.Property("Wall") + .HasPrecision(10, 4) + .HasColumnType("decimal(10,4)"); + + b.HasIndex("Size"); + + b.ToTable("DimSquareTube", (string)null); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.Job", b => + { + b.HasOne("CutList.Web.Data.Entities.CuttingTool", "CuttingTool") + .WithMany("Jobs") + .HasForeignKey("CuttingToolId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("CuttingTool"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.JobPart", b => + { + b.HasOne("CutList.Web.Data.Entities.Job", "Job") + .WithMany("Parts") + .HasForeignKey("JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CutList.Web.Data.Entities.Material", "Material") + .WithMany("JobParts") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Job"); + + b.Navigation("Material"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.JobStock", b => + { + b.HasOne("CutList.Web.Data.Entities.Job", "Job") + .WithMany("Stock") + .HasForeignKey("JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CutList.Web.Data.Entities.Material", "Material") + .WithMany() + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem") + .WithMany() + .HasForeignKey("StockItemId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Job"); + + b.Navigation("Material"); + + b.Navigation("StockItem"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.MaterialDimensions", b => + { + b.HasOne("CutList.Web.Data.Entities.Material", "Material") + .WithOne("Dimensions") + .HasForeignKey("CutList.Web.Data.Entities.MaterialDimensions", "MaterialId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Material"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b => + { + b.HasOne("CutList.Web.Data.Entities.Material", "Material") + .WithMany("StockItems") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Material"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.StockTransaction", b => + { + b.HasOne("CutList.Web.Data.Entities.Job", "Job") + .WithMany() + .HasForeignKey("JobId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem") + .WithMany("Transactions") + .HasForeignKey("StockItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Job"); + + b.Navigation("StockItem"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.CuttingTool", b => + { + b.Navigation("Jobs"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.Job", b => + { + b.Navigation("Parts"); + + b.Navigation("Stock"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.Material", b => + { + b.Navigation("Dimensions"); + + b.Navigation("JobParts"); + + b.Navigation("StockItems"); + }); + + modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b => + { + b.Navigation("Transactions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CutList.Web/Migrations/20260801124832_RemoveVendorData.cs b/CutList.Web/Migrations/20260801124832_RemoveVendorData.cs new file mode 100644 index 0000000..db30a5d --- /dev/null +++ b/CutList.Web/Migrations/20260801124832_RemoveVendorData.cs @@ -0,0 +1,183 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CutList.Web.Migrations +{ + /// + public partial class RemoveVendorData : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_StockTransactions_Suppliers_SupplierId", + table: "StockTransactions"); + + migrationBuilder.DropTable( + name: "PurchaseItems"); + + migrationBuilder.DropTable( + name: "SupplierOfferings"); + + migrationBuilder.DropTable( + name: "Suppliers"); + + migrationBuilder.DropIndex( + name: "IX_StockTransactions_SupplierId", + table: "StockTransactions"); + + migrationBuilder.DropColumn( + name: "SupplierId", + table: "StockTransactions"); + + migrationBuilder.DropColumn( + name: "UnitPrice", + table: "StockTransactions"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SupplierId", + table: "StockTransactions", + type: "int", + nullable: true); + + migrationBuilder.AddColumn( + name: "UnitPrice", + table: "StockTransactions", + type: "decimal(10,2)", + precision: 10, + scale: 2, + nullable: true); + + migrationBuilder.CreateTable( + name: "Suppliers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ContactInfo = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"), + IsActive = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + Notes = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Suppliers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "PurchaseItems", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + JobId = table.Column(type: "int", nullable: true), + StockItemId = table.Column(type: "int", nullable: false), + SupplierId = table.Column(type: "int", nullable: true), + CreatedAt = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"), + Notes = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + Quantity = table.Column(type: "int", nullable: false), + Status = table.Column(type: "nvarchar(20)", maxLength: 20, nullable: false), + UpdatedAt = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PurchaseItems", x => x.Id); + table.ForeignKey( + name: "FK_PurchaseItems_Jobs_JobId", + column: x => x.JobId, + principalTable: "Jobs", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + table.ForeignKey( + name: "FK_PurchaseItems_StockItems_StockItemId", + column: x => x.StockItemId, + principalTable: "StockItems", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PurchaseItems_Suppliers_SupplierId", + column: x => x.SupplierId, + principalTable: "Suppliers", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "SupplierOfferings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + StockItemId = table.Column(type: "int", nullable: false), + SupplierId = table.Column(type: "int", nullable: false), + IsActive = table.Column(type: "bit", nullable: false), + Notes = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + PartNumber = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + Price = table.Column(type: "decimal(10,2)", precision: 10, scale: 2, nullable: true), + SupplierDescription = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SupplierOfferings", x => x.Id); + table.ForeignKey( + name: "FK_SupplierOfferings_StockItems_StockItemId", + column: x => x.StockItemId, + principalTable: "StockItems", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_SupplierOfferings_Suppliers_SupplierId", + column: x => x.SupplierId, + principalTable: "Suppliers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_StockTransactions_SupplierId", + table: "StockTransactions", + column: "SupplierId"); + + migrationBuilder.CreateIndex( + name: "IX_PurchaseItems_JobId", + table: "PurchaseItems", + column: "JobId"); + + migrationBuilder.CreateIndex( + name: "IX_PurchaseItems_StockItemId", + table: "PurchaseItems", + column: "StockItemId"); + + migrationBuilder.CreateIndex( + name: "IX_PurchaseItems_SupplierId", + table: "PurchaseItems", + column: "SupplierId"); + + migrationBuilder.CreateIndex( + name: "IX_SupplierOfferings_StockItemId", + table: "SupplierOfferings", + column: "StockItemId"); + + migrationBuilder.CreateIndex( + name: "IX_SupplierOfferings_SupplierId_StockItemId", + table: "SupplierOfferings", + columns: new[] { "SupplierId", "StockItemId" }, + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_StockTransactions_Suppliers_SupplierId", + table: "StockTransactions", + column: "SupplierId", + principalTable: "Suppliers", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + } +} diff --git a/CutList.Web/Migrations/ApplicationDbContextModelSnapshot.cs b/CutList.Web/Migrations/ApplicationDbContextModelSnapshot.cs index 38a2d91..df24b30 100644 --- a/CutList.Web/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/CutList.Web/Migrations/ApplicationDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ namespace CutList.Web.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("ProductVersion", "10.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -294,54 +294,6 @@ namespace CutList.Web.Migrations b.UseTpcMappingStrategy(); }); - modelBuilder.Entity("CutList.Web.Data.Entities.PurchaseItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETUTCDATE()"); - - b.Property("JobId") - .HasColumnType("int"); - - b.Property("Notes") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("Status") - .IsRequired() - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("StockItemId") - .HasColumnType("int"); - - b.Property("SupplierId") - .HasColumnType("int"); - - b.Property("UpdatedAt") - .HasColumnType("datetime2"); - - b.HasKey("Id"); - - b.HasIndex("JobId"); - - b.HasIndex("StockItemId"); - - b.HasIndex("SupplierId"); - - b.ToTable("PurchaseItems"); - }); - modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b => { b.Property("Id") @@ -413,103 +365,18 @@ namespace CutList.Web.Migrations b.Property("StockItemId") .HasColumnType("int"); - b.Property("SupplierId") - .HasColumnType("int"); - b.Property("Type") .HasColumnType("int"); - b.Property("UnitPrice") - .HasPrecision(10, 2) - .HasColumnType("decimal(10,2)"); - b.HasKey("Id"); b.HasIndex("JobId"); b.HasIndex("StockItemId"); - b.HasIndex("SupplierId"); - b.ToTable("StockTransactions"); }); - modelBuilder.Entity("CutList.Web.Data.Entities.Supplier", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ContactInfo") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b.Property("CreatedAt") - .ValueGeneratedOnAdd() - .HasColumnType("datetime2") - .HasDefaultValueSql("GETUTCDATE()"); - - b.Property("IsActive") - .HasColumnType("bit"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Notes") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Suppliers"); - }); - - modelBuilder.Entity("CutList.Web.Data.Entities.SupplierOffering", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("IsActive") - .HasColumnType("bit"); - - b.Property("Notes") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("PartNumber") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Price") - .HasPrecision(10, 2) - .HasColumnType("decimal(10,2)"); - - b.Property("StockItemId") - .HasColumnType("int"); - - b.Property("SupplierDescription") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b.Property("SupplierId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("StockItemId"); - - b.HasIndex("SupplierId", "StockItemId") - .IsUnique(); - - b.ToTable("SupplierOfferings"); - }); - modelBuilder.Entity("CutList.Web.Data.Entities.AngleDimensions", b => { b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions"); @@ -754,31 +621,6 @@ namespace CutList.Web.Migrations b.Navigation("Material"); }); - modelBuilder.Entity("CutList.Web.Data.Entities.PurchaseItem", b => - { - b.HasOne("CutList.Web.Data.Entities.Job", "Job") - .WithMany() - .HasForeignKey("JobId") - .OnDelete(DeleteBehavior.SetNull); - - b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem") - .WithMany() - .HasForeignKey("StockItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("CutList.Web.Data.Entities.Supplier", "Supplier") - .WithMany() - .HasForeignKey("SupplierId") - .OnDelete(DeleteBehavior.SetNull); - - b.Navigation("Job"); - - b.Navigation("StockItem"); - - b.Navigation("Supplier"); - }); - modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b => { b.HasOne("CutList.Web.Data.Entities.Material", "Material") @@ -803,35 +645,9 @@ namespace CutList.Web.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("CutList.Web.Data.Entities.Supplier", "Supplier") - .WithMany() - .HasForeignKey("SupplierId") - .OnDelete(DeleteBehavior.SetNull); - b.Navigation("Job"); b.Navigation("StockItem"); - - b.Navigation("Supplier"); - }); - - modelBuilder.Entity("CutList.Web.Data.Entities.SupplierOffering", b => - { - b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem") - .WithMany("SupplierOfferings") - .HasForeignKey("StockItemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("CutList.Web.Data.Entities.Supplier", "Supplier") - .WithMany("Offerings") - .HasForeignKey("SupplierId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("StockItem"); - - b.Navigation("Supplier"); }); modelBuilder.Entity("CutList.Web.Data.Entities.CuttingTool", b => @@ -857,15 +673,8 @@ namespace CutList.Web.Migrations modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b => { - b.Navigation("SupplierOfferings"); - b.Navigation("Transactions"); }); - - modelBuilder.Entity("CutList.Web.Data.Entities.Supplier", b => - { - b.Navigation("Offerings"); - }); #pragma warning restore 612, 618 } }