refactor: Update Material and StockItem entities

Material entity changes:
- Shape property now uses MaterialShape enum
- Add Type (MaterialType) and Grade properties
- Add SortOrder for numeric sorting
- Add Dimensions navigation property (1:1)
- Replace ProjectParts with JobParts collection

StockItem entity changes:
- Add QuantityOnHand for inventory tracking
- Add Notes field
- Add Transactions navigation property

DbContext updates:
- Configure MaterialDimensions TPH inheritance
- Add enum-to-string conversions for MaterialShape and MaterialType
- Configure shared column names for TPH properties
- Add indexes on primary dimension columns
- Update all entity relationships for Job model

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-04 23:37:51 -05:00
parent 4f6d986dc9
commit 3b036308c8
4 changed files with 670 additions and 130 deletions

View File

@@ -3,16 +3,36 @@ namespace CutList.Web.Data.Entities;
public class Material
{
public int Id { get; set; }
public string Shape { get; set; } = string.Empty;
public MaterialShape Shape { get; set; }
/// <summary>
/// Material type (Steel, Aluminum, Stainless, etc.)
/// </summary>
public MaterialType Type { get; set; }
/// <summary>
/// Grade or specification (e.g., "A36", "Hot Roll", "304", "6061-T6")
/// </summary>
public string? Grade { get; set; }
public string Size { get; set; } = string.Empty;
public string? Description { get; set; }
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? UpdatedAt { get; set; }
public ICollection<StockItem> StockItems { get; set; } = new List<StockItem>();
public ICollection<MaterialStockLength> StockLengths { get; set; } = new List<MaterialStockLength>();
public ICollection<ProjectPart> ProjectParts { get; set; } = new List<ProjectPart>();
/// <summary>
/// Sort order based on primary dimension (stored as thousandths of an inch for numeric sorting).
/// </summary>
public int SortOrder { get; set; }
public string DisplayName => $"{Shape} - {Size}";
public ICollection<StockItem> StockItems { get; set; } = new List<StockItem>();
public ICollection<JobPart> JobParts { get; set; } = new List<JobPart>();
/// <summary>
/// Optional parsed dimensions for decimal-based searching.
/// </summary>
public MaterialDimensions? Dimensions { get; set; }
public string DisplayName => $"{Shape.GetDisplayName()} - {Size}";
}

View File

@@ -6,10 +6,13 @@ public class StockItem
public int MaterialId { get; set; }
public decimal LengthInches { get; set; }
public string? Name { get; set; }
public int QuantityOnHand { get; set; } = 0;
public string? Notes { get; set; }
public bool IsActive { get; set; } = true;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? UpdatedAt { get; set; }
public Material Material { get; set; } = null!;
public ICollection<SupplierOffering> SupplierOfferings { get; set; } = new List<SupplierOffering>();
public ICollection<StockTransaction> Transactions { get; set; } = new List<StockTransaction>();
}