Created API Controllers (#1)

Removed strongly typed inventory objects

Added EAV inventory types

Added EAV object handling philosophy

Added controllers

Added EF Core migration integration

Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
2026-05-02 19:24:06 -05:00
parent 4674529b91
commit 0b357e1e13
47 changed files with 1252 additions and 219 deletions
@@ -0,0 +1,182 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using WyvernInventory.Infrastructure.Data;
#nullable disable
namespace WyvernInventory.Infrastructure.Migrations
{
[DbContext(typeof(DBContext))]
[Migration("20260501023055_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeDefinition", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("DataType")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int?>("TypeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TypeId");
b.ToTable("InventoryAttributeDefinitions");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeValue", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AttributeDefinitionId")
.HasColumnType("int");
b.Property<bool?>("BoolValue")
.HasColumnType("bit");
b.Property<DateTime?>("DateTimeValue")
.HasColumnType("datetime2");
b.Property<decimal?>("DecimalValue")
.HasColumnType("decimal(18,2)");
b.Property<int?>("IntValue")
.HasColumnType("int");
b.Property<int>("ItemId")
.HasColumnType("int");
b.Property<string>("StringValue")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AttributeDefinitionId");
b.HasIndex("ItemId", "AttributeDefinitionId")
.IsUnique();
b.ToTable("InventoryAttributeValues");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TypeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TypeId");
b.ToTable("InventoryItems");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("InventoryTypes");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeDefinition", b =>
{
b.HasOne("WyvernInventory.Core.Models.InventoryType", "Type")
.WithMany("AttributeDefinitions")
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade);
b.Navigation("Type");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeValue", b =>
{
b.HasOne("WyvernInventory.Core.Models.InventoryAttributeDefinition", "AttributeDefinition")
.WithMany()
.HasForeignKey("AttributeDefinitionId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("WyvernInventory.Core.Models.InventoryItem", "Item")
.WithMany("AttributeValues")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AttributeDefinition");
b.Navigation("Item");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryItem", b =>
{
b.HasOne("WyvernInventory.Core.Models.InventoryType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Type");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryItem", b =>
{
b.Navigation("AttributeValues");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryType", b =>
{
b.Navigation("AttributeDefinitions");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,136 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WyvernInventory.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "InventoryTypes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InventoryTypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "InventoryAttributeDefinitions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TypeId = table.Column<int>(type: "int", nullable: true),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
DataType = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_InventoryAttributeDefinitions", x => x.Id);
table.ForeignKey(
name: "FK_InventoryAttributeDefinitions_InventoryTypes_TypeId",
column: x => x.TypeId,
principalTable: "InventoryTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InventoryItems",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
TypeId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InventoryItems", x => x.Id);
table.ForeignKey(
name: "FK_InventoryItems_InventoryTypes_TypeId",
column: x => x.TypeId,
principalTable: "InventoryTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InventoryAttributeValues",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ItemId = table.Column<int>(type: "int", nullable: false),
AttributeDefinitionId = table.Column<int>(type: "int", nullable: false),
StringValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
IntValue = table.Column<int>(type: "int", nullable: true),
DecimalValue = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
BoolValue = table.Column<bool>(type: "bit", nullable: true),
DateTimeValue = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_InventoryAttributeValues", x => x.Id);
table.ForeignKey(
name: "FK_InventoryAttributeValues_InventoryAttributeDefinitions_AttributeDefinitionId",
column: x => x.AttributeDefinitionId,
principalTable: "InventoryAttributeDefinitions",
principalColumn: "Id");
table.ForeignKey(
name: "FK_InventoryAttributeValues_InventoryItems_ItemId",
column: x => x.ItemId,
principalTable: "InventoryItems",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_InventoryAttributeDefinitions_TypeId",
table: "InventoryAttributeDefinitions",
column: "TypeId");
migrationBuilder.CreateIndex(
name: "IX_InventoryAttributeValues_AttributeDefinitionId",
table: "InventoryAttributeValues",
column: "AttributeDefinitionId");
migrationBuilder.CreateIndex(
name: "IX_InventoryAttributeValues_ItemId_AttributeDefinitionId",
table: "InventoryAttributeValues",
columns: new[] { "ItemId", "AttributeDefinitionId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_InventoryItems_TypeId",
table: "InventoryItems",
column: "TypeId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "InventoryAttributeValues");
migrationBuilder.DropTable(
name: "InventoryAttributeDefinitions");
migrationBuilder.DropTable(
name: "InventoryItems");
migrationBuilder.DropTable(
name: "InventoryTypes");
}
}
}
@@ -0,0 +1,179 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using WyvernInventory.Infrastructure.Data;
#nullable disable
namespace WyvernInventory.Infrastructure.Migrations
{
[DbContext(typeof(DBContext))]
partial class DBContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeDefinition", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("DataType")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int?>("TypeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TypeId");
b.ToTable("InventoryAttributeDefinitions");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeValue", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AttributeDefinitionId")
.HasColumnType("int");
b.Property<bool?>("BoolValue")
.HasColumnType("bit");
b.Property<DateTime?>("DateTimeValue")
.HasColumnType("datetime2");
b.Property<decimal?>("DecimalValue")
.HasColumnType("decimal(18,2)");
b.Property<int?>("IntValue")
.HasColumnType("int");
b.Property<int>("ItemId")
.HasColumnType("int");
b.Property<string>("StringValue")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AttributeDefinitionId");
b.HasIndex("ItemId", "AttributeDefinitionId")
.IsUnique();
b.ToTable("InventoryAttributeValues");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TypeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TypeId");
b.ToTable("InventoryItems");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("InventoryTypes");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeDefinition", b =>
{
b.HasOne("WyvernInventory.Core.Models.InventoryType", "Type")
.WithMany("AttributeDefinitions")
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade);
b.Navigation("Type");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryAttributeValue", b =>
{
b.HasOne("WyvernInventory.Core.Models.InventoryAttributeDefinition", "AttributeDefinition")
.WithMany()
.HasForeignKey("AttributeDefinitionId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.HasOne("WyvernInventory.Core.Models.InventoryItem", "Item")
.WithMany("AttributeValues")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AttributeDefinition");
b.Navigation("Item");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryItem", b =>
{
b.HasOne("WyvernInventory.Core.Models.InventoryType", "Type")
.WithMany()
.HasForeignKey("TypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Type");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryItem", b =>
{
b.Navigation("AttributeValues");
});
modelBuilder.Entity("WyvernInventory.Core.Models.InventoryType", b =>
{
b.Navigation("AttributeDefinitions");
});
#pragma warning restore 612, 618
}
}
}