Migrations
Fixes
This commit is contained in:
parent
ab5ffcbfbf
commit
3fd6b1e6eb
241
RouteGuide/RouteGuideDatabaseImplement/Migrations/20240407200755_InitialCreate.Designer.cs
generated
Normal file
241
RouteGuide/RouteGuideDatabaseImplement/Migrations/20240407200755_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,241 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using RouteGuideDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RouteGuideDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(RouteGuideDatabase))]
|
||||
[Migration("20240407200755_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.13")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Driver", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("Experience")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Drivers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Route", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("TransportId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TransportId");
|
||||
|
||||
b.ToTable("Routes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.RouteStop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Number")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RouteId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StopId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RouteId");
|
||||
|
||||
b.HasIndex("StopId");
|
||||
|
||||
b.ToTable("RouteStops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Schedule", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("ArrivalTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DepartureTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("Frequency")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("RouteId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RouteId");
|
||||
|
||||
b.ToTable("Schedules");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Stop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Number")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Street")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Stops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DriverId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("License")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DriverId");
|
||||
|
||||
b.ToTable("Transport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Route", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Transport", "Transport")
|
||||
.WithMany()
|
||||
.HasForeignKey("TransportId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Transport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.RouteStop", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Route", "Route")
|
||||
.WithMany("Stops")
|
||||
.HasForeignKey("RouteId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Stop", "Stop")
|
||||
.WithMany()
|
||||
.HasForeignKey("StopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Route");
|
||||
|
||||
b.Navigation("Stop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Schedule", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Route", "Route")
|
||||
.WithMany()
|
||||
.HasForeignKey("RouteId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Route");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Driver", "Driver")
|
||||
.WithMany()
|
||||
.HasForeignKey("DriverId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Driver");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Route", b =>
|
||||
{
|
||||
b.Navigation("Stops");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RouteGuideDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Drivers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
FullName = table.Column<string>(type: "text", nullable: false),
|
||||
Phone = table.Column<string>(type: "text", nullable: false),
|
||||
Experience = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Drivers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Stops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Street = table.Column<string>(type: "text", nullable: false),
|
||||
Number = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Stops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Transport",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
License = table.Column<string>(type: "text", nullable: false),
|
||||
Type = table.Column<int>(type: "integer", nullable: false),
|
||||
Capacity = table.Column<int>(type: "integer", nullable: false),
|
||||
DriverId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Transport", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Transport_Drivers_DriverId",
|
||||
column: x => x.DriverId,
|
||||
principalTable: "Drivers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Routes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
TransportId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Routes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Routes_Transport_TransportId",
|
||||
column: x => x.TransportId,
|
||||
principalTable: "Transport",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RouteStops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
RouteId = table.Column<int>(type: "integer", nullable: false),
|
||||
StopId = table.Column<int>(type: "integer", nullable: false),
|
||||
Number = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RouteStops", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RouteStops_Routes_RouteId",
|
||||
column: x => x.RouteId,
|
||||
principalTable: "Routes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RouteStops_Stops_StopId",
|
||||
column: x => x.StopId,
|
||||
principalTable: "Stops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Schedules",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
DepartureTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
ArrivalTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Frequency = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
RouteId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Schedules", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Schedules_Routes_RouteId",
|
||||
column: x => x.RouteId,
|
||||
principalTable: "Routes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Routes_TransportId",
|
||||
table: "Routes",
|
||||
column: "TransportId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RouteStops_RouteId",
|
||||
table: "RouteStops",
|
||||
column: "RouteId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RouteStops_StopId",
|
||||
table: "RouteStops",
|
||||
column: "StopId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Schedules_RouteId",
|
||||
table: "Schedules",
|
||||
column: "RouteId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Transport_DriverId",
|
||||
table: "Transport",
|
||||
column: "DriverId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "RouteStops");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Schedules");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Stops");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Routes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Transport");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Drivers");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,238 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using RouteGuideDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace RouteGuideDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(RouteGuideDatabase))]
|
||||
partial class RouteGuideDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.13")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Driver", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("Experience")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("FullName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Phone")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Drivers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Route", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("TransportId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TransportId");
|
||||
|
||||
b.ToTable("Routes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.RouteStop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Number")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RouteId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("StopId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RouteId");
|
||||
|
||||
b.HasIndex("StopId");
|
||||
|
||||
b.ToTable("RouteStops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Schedule", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("ArrivalTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DepartureTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("Frequency")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("RouteId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RouteId");
|
||||
|
||||
b.ToTable("Schedules");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Stop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Number")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("Street")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Stops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("DriverId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("License")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DriverId");
|
||||
|
||||
b.ToTable("Transport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Route", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Transport", "Transport")
|
||||
.WithMany()
|
||||
.HasForeignKey("TransportId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Transport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.RouteStop", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Route", "Route")
|
||||
.WithMany("Stops")
|
||||
.HasForeignKey("RouteId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Stop", "Stop")
|
||||
.WithMany()
|
||||
.HasForeignKey("StopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Route");
|
||||
|
||||
b.Navigation("Stop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Schedule", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Route", "Route")
|
||||
.WithMany()
|
||||
.HasForeignKey("RouteId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Route");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.HasOne("RouteGuideDatabaseImplement.Models.Driver", "Driver")
|
||||
.WithMany()
|
||||
.HasForeignKey("DriverId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Driver");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("RouteGuideDatabaseImplement.Models.Route", b =>
|
||||
{
|
||||
b.Navigation("Stops");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -99,6 +99,7 @@ namespace RouteGuideDatabaseImplement.Models
|
||||
Id = Id,
|
||||
License = License,
|
||||
Type = Type,
|
||||
Capacity= Capacity,
|
||||
DriverId = DriverId,
|
||||
DriverName = Driver.FullName
|
||||
};
|
||||
|
26
RouteGuide/RouteGuideView/FormRoute.Designer.cs
generated
26
RouteGuide/RouteGuideView/FormRoute.Designer.cs
generated
@ -41,6 +41,8 @@
|
||||
ColumnNumber = new DataGridViewTextBoxColumn();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxTransport = new ComboBox();
|
||||
labelTransport = new Label();
|
||||
groupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -49,7 +51,7 @@
|
||||
//
|
||||
textBoxName.Location = new Point(80, 12);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(200, 23);
|
||||
textBoxName.Size = new Size(150, 23);
|
||||
textBoxName.TabIndex = 0;
|
||||
//
|
||||
// labelName
|
||||
@ -173,11 +175,31 @@
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// comboBoxTransport
|
||||
//
|
||||
comboBoxTransport.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTransport.FormattingEnabled = true;
|
||||
comboBoxTransport.Location = new Point(395, 12);
|
||||
comboBoxTransport.Name = "comboBoxTransport";
|
||||
comboBoxTransport.Size = new Size(150, 23);
|
||||
comboBoxTransport.TabIndex = 10;
|
||||
//
|
||||
// labelTransport
|
||||
//
|
||||
labelTransport.AutoSize = true;
|
||||
labelTransport.Location = new Point(321, 15);
|
||||
labelTransport.Name = "labelTransport";
|
||||
labelTransport.Size = new Size(68, 15);
|
||||
labelTransport.TabIndex = 11;
|
||||
labelTransport.Text = "Транспорт:";
|
||||
//
|
||||
// FormRoute
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(684, 361);
|
||||
Controls.Add(labelTransport);
|
||||
Controls.Add(comboBoxTransport);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(groupBox);
|
||||
@ -207,5 +229,7 @@
|
||||
private DataGridViewTextBoxColumn ColumnId;
|
||||
private DataGridViewTextBoxColumn ColumnName;
|
||||
private DataGridViewTextBoxColumn ColumnNumber;
|
||||
private ComboBox comboBoxTransport;
|
||||
private Label labelTransport;
|
||||
}
|
||||
}
|
@ -27,10 +27,15 @@ namespace RouteGuideView
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика
|
||||
/// Бизнес-логика маршрутов
|
||||
/// </summary>
|
||||
private readonly IRouteLogic _routeLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Бизнес-логика транспорта
|
||||
/// </summary>
|
||||
private readonly ITransportLogic _transportLogic;
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор
|
||||
/// </summary>
|
||||
@ -51,11 +56,12 @@ namespace RouteGuideView
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="routeLogic"></param>
|
||||
public FormRoute(ILogger<FormRoute> logger, IRouteLogic routeLogic)
|
||||
public FormRoute(ILogger<FormRoute> logger, IRouteLogic routeLogic, ITransportLogic transportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_routeLogic = routeLogic;
|
||||
_transportLogic = transportLogic;
|
||||
_routeStops = new Dictionary<int, (IStopModel, int)>();
|
||||
}
|
||||
|
||||
@ -66,6 +72,25 @@ namespace RouteGuideView
|
||||
/// <param name="e"></param>
|
||||
private void FormRoute_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Загрузка маршрутов для ComboBoxTransport
|
||||
_logger.LogInformation("Загрузка списка транспорта");
|
||||
var list = _transportLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxTransport.DisplayMember = "License";
|
||||
comboBoxTransport.ValueMember = "Id";
|
||||
comboBoxTransport.DataSource = list;
|
||||
comboBoxTransport.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка транспорта");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
if (!_id.HasValue)
|
||||
{
|
||||
return;
|
||||
@ -81,6 +106,7 @@ namespace RouteGuideView
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.Name;
|
||||
comboBoxTransport.SelectedValue = view.TransportId;
|
||||
_routeStops = view.RouteStops ?? new Dictionary<int, (IStopModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
@ -202,6 +228,11 @@ namespace RouteGuideView
|
||||
MessageBox.Show("Заполните название маршрута", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxTransport.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение сущности 'Маршрут'");
|
||||
try
|
||||
@ -210,6 +241,7 @@ namespace RouteGuideView
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Name = textBoxName.Text,
|
||||
TransportId = Convert.ToInt32(comboBoxTransport.SelectedValue),
|
||||
RouteStops = _routeStops
|
||||
};
|
||||
|
||||
|
@ -126,13 +126,4 @@
|
||||
<metadata name="ColumnNumber.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnNumber.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -38,6 +38,7 @@
|
||||
//
|
||||
// comboBoxStop
|
||||
//
|
||||
comboBoxStop.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxStop.FormattingEnabled = true;
|
||||
comboBoxStop.Location = new Point(80, 7);
|
||||
comboBoxStop.Name = "comboBoxStop";
|
||||
|
@ -75,6 +75,7 @@
|
||||
//
|
||||
// comboBoxRoute
|
||||
//
|
||||
comboBoxRoute.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRoute.FormattingEnabled = true;
|
||||
comboBoxRoute.Location = new Point(101, 12);
|
||||
comboBoxRoute.Name = "comboBoxRoute";
|
||||
|
@ -140,6 +140,7 @@ namespace RouteGuideView
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка остановок");
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
//
|
||||
// comboBoxType
|
||||
//
|
||||
comboBoxType.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxType.FormattingEnabled = true;
|
||||
comboBoxType.Location = new Point(101, 12);
|
||||
comboBoxType.Name = "comboBoxType";
|
||||
@ -50,6 +51,7 @@
|
||||
//
|
||||
// comboBoxDriver
|
||||
//
|
||||
comboBoxDriver.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxDriver.FormattingEnabled = true;
|
||||
comboBoxDriver.Location = new Point(101, 41);
|
||||
comboBoxDriver.Name = "comboBoxDriver";
|
||||
|
@ -109,7 +109,7 @@ namespace RouteGuideView
|
||||
{
|
||||
textBoxLicense.Text = view.License;
|
||||
textBoxCapacity.Text = view.Capacity.ToString();
|
||||
comboBoxDriver.SelectedItem = view.DriverId;
|
||||
comboBoxDriver.SelectedValue = view.DriverId;
|
||||
comboBoxType.SelectedItem = view.Type;
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ namespace RouteGuideView
|
||||
/// <param name="e"></param>
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxType.SelectedValue == null)
|
||||
if (comboBoxType.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show("Выберите тип транспорта", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
@ -155,7 +155,7 @@ namespace RouteGuideView
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
License = textBoxLicense.Text,
|
||||
Type = (TransportType)comboBoxType.SelectedValue,
|
||||
Type = (TransportType)comboBoxType.SelectedItem,
|
||||
Capacity = int.TryParse(textBoxCapacity.Text, out var capacity) ? capacity : 1,
|
||||
DriverId = Convert.ToInt32(comboBoxDriver.SelectedValue)
|
||||
};
|
||||
|
@ -141,6 +141,7 @@ namespace RouteGuideView
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["DriverId"].Visible = false;
|
||||
dataGridView.Columns["DriverName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка транспорта");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user