feat: Add material dimensions with typed properties
Implement TPH inheritance for material dimensions: - MaterialShape enum with display names and parsing - MaterialType enum (Steel, Aluminum, Stainless, etc.) - MaterialDimensions base class with derived types per shape - Auto-generate size strings from typed dimensions - SortOrder field for numeric dimension sorting Each shape has specific dimension properties: - RoundBar: Diameter - RoundTube: OuterDiameter, Wall - FlatBar: Width, Thickness - SquareBar/Tube: Size, Wall - RectangularTube: Width, Height, Wall - Angle: Leg1, Leg2, Thickness - Channel: Height, Flange, Web - IBeam: Height, WeightPerFoot - Pipe: NominalSize, Wall, Schedule Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace CutList.Web.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class UpdateExistingSortOrders : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
// Update SortOrder for existing materials based on their primary dimension
|
||||
migrationBuilder.Sql(@"
|
||||
UPDATE m
|
||||
SET m.SortOrder = CAST(
|
||||
CASE d.DimensionType
|
||||
WHEN 'RoundBar' THEN d.Diameter * 1000
|
||||
WHEN 'RoundTube' THEN d.OuterDiameter * 1000
|
||||
WHEN 'FlatBar' THEN d.Width * 1000
|
||||
WHEN 'SquareBar' THEN d.Size * 1000
|
||||
WHEN 'SquareTube' THEN d.Size * 1000
|
||||
WHEN 'RectangularTube' THEN d.Width * 1000
|
||||
WHEN 'Angle' THEN d.Leg1 * 1000
|
||||
WHEN 'Channel' THEN d.Height * 1000
|
||||
WHEN 'IBeam' THEN d.Height * 1000
|
||||
WHEN 'Pipe' THEN d.NominalSize * 1000
|
||||
ELSE 0
|
||||
END AS INT)
|
||||
FROM Materials m
|
||||
INNER JOIN MaterialDimensions d ON d.MaterialId = m.Id
|
||||
");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user