mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 08:23:12 +00:00
- Extend Locations model with Address, City, State, ZipCode, Phone, Contact, ContactEmail, Status, AccountId
- Update Location DTOs to match new fields
- Create LocationController with paged list, get by ID, create, update, delete
- Support both REST-style routes (/api/Location/{id}) and legacy query routes (/api/Location/DeleteLocation?id=)
- Add migration for new Location columns
129 lines
3.8 KiB
C#
129 lines
3.8 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Data.SeaHavenIndustries.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddLocationFields : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "AccountId",
|
|
table: "Locations",
|
|
type: "int",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Address",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "City",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Contact",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "ContactEmail",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Phone",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "State",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Status",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "ZipCode",
|
|
table: "Locations",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Locations_AccountId",
|
|
table: "Locations",
|
|
column: "AccountId");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_Locations_Accounts_AccountId",
|
|
table: "Locations",
|
|
column: "AccountId",
|
|
principalTable: "Accounts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_Locations_Accounts_AccountId",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Locations_AccountId",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "AccountId",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Address",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "City",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Contact",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ContactEmail",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Phone",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "State",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Status",
|
|
table: "Locations");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "ZipCode",
|
|
table: "Locations");
|
|
}
|
|
}
|
|
}
|