From a1e7ac32112c1c322d075bfdf0a6477e2b78042a Mon Sep 17 00:00:00 2001 From: sardq Date: Thu, 30 May 2024 02:29:51 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=81=D0=B5=3F...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FactoryDatabaseImplement.csproj | 4 ++++ ...igner.cs => 20240529212521_Init.Designer.cs} | 17 +++++++---------- ...223_InitCreate.cs => 20240529212521_Init.cs} | 5 ++--- .../Migrations/FactoryDatabaseModelSnapshot.cs | 13 +++++-------- .../Controllers/HomeController.cs | 5 +++++ .../Views/Home/PlanProductions.cshtml | 2 +- 6 files changed, 24 insertions(+), 22 deletions(-) rename Factory/FactoryDatabaseImplement/Migrations/{20240528144223_InitCreate.Designer.cs => 20240529212521_Init.Designer.cs} (97%) rename Factory/FactoryDatabaseImplement/Migrations/{20240528144223_InitCreate.cs => 20240529212521_Init.cs} (99%) diff --git a/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj b/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj index 055429e..46ea071 100644 --- a/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj +++ b/Factory/FactoryDatabaseImplement/FactoryDatabaseImplement.csproj @@ -23,4 +23,8 @@ + + + + diff --git a/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.Designer.cs b/Factory/FactoryDatabaseImplement/Migrations/20240529212521_Init.Designer.cs similarity index 97% rename from Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.Designer.cs rename to Factory/FactoryDatabaseImplement/Migrations/20240529212521_Init.Designer.cs index 2ca0020..e8cb4ff 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.Designer.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/20240529212521_Init.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FactoryDatabaseImplement.Migrations { [DbContext(typeof(FactoryDatabase))] - [Migration("20240528144223_InitCreate")] - partial class InitCreate + [Migration("20240529212521_Init")] + partial class Init { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -71,7 +71,8 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired() .HasColumnType("text"); - b.Property("PlanProductionId") + b.Property("PlanProductionId") + .IsRequired() .HasColumnType("integer"); b.Property("Status") @@ -81,8 +82,7 @@ namespace FactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("PlanProductionId") - .IsUnique(); + b.HasIndex("PlanProductionId"); b.ToTable("ExecutionPhases"); }); @@ -345,8 +345,8 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired(); b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction") - .WithOne("ExecutionPhase") - .HasForeignKey("FactoryDatabaseImplement.Models.ExecutionPhase", "PlanProductionId") + .WithMany() + .HasForeignKey("PlanProductionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -518,9 +518,6 @@ namespace FactoryDatabaseImplement.Migrations modelBuilder.Entity("FactoryDatabaseImplement.Models.PlanProduction", b => { - b.Navigation("ExecutionPhase") - .IsRequired(); - b.Navigation("Machines"); b.Navigation("Workpieces"); diff --git a/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.cs b/Factory/FactoryDatabaseImplement/Migrations/20240529212521_Init.cs similarity index 99% rename from Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.cs rename to Factory/FactoryDatabaseImplement/Migrations/20240529212521_Init.cs index 0bfa318..85340a9 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/20240529212521_Init.cs @@ -6,7 +6,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FactoryDatabaseImplement.Migrations { - public partial class InitCreate : Migration + public partial class Init : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -287,8 +287,7 @@ namespace FactoryDatabaseImplement.Migrations migrationBuilder.CreateIndex( name: "IX_ExecutionPhases_PlanProductionId", table: "ExecutionPhases", - column: "PlanProductionId", - unique: true); + column: "PlanProductionId"); migrationBuilder.CreateIndex( name: "IX_MachinePlanProductions_MachineId", diff --git a/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs b/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs index b06323e..8d65b70 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs @@ -69,7 +69,8 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired() .HasColumnType("text"); - b.Property("PlanProductionId") + b.Property("PlanProductionId") + .IsRequired() .HasColumnType("integer"); b.Property("Status") @@ -79,8 +80,7 @@ namespace FactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("PlanProductionId") - .IsUnique(); + b.HasIndex("PlanProductionId"); b.ToTable("ExecutionPhases"); }); @@ -343,8 +343,8 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired(); b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction") - .WithOne("ExecutionPhase") - .HasForeignKey("FactoryDatabaseImplement.Models.ExecutionPhase", "PlanProductionId") + .WithMany() + .HasForeignKey("PlanProductionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -516,9 +516,6 @@ namespace FactoryDatabaseImplement.Migrations modelBuilder.Entity("FactoryDatabaseImplement.Models.PlanProduction", b => { - b.Navigation("ExecutionPhase") - .IsRequired(); - b.Navigation("Machines"); b.Navigation("Workpieces"); diff --git a/Factory/FactoryWorkerApp/Controllers/HomeController.cs b/Factory/FactoryWorkerApp/Controllers/HomeController.cs index 5b32edc..a02c317 100644 --- a/Factory/FactoryWorkerApp/Controllers/HomeController.cs +++ b/Factory/FactoryWorkerApp/Controllers/HomeController.cs @@ -302,6 +302,11 @@ namespace FactoryWorkerApp.Controllers DateFrom = startDate, DateTo = endDate, }); + foreach( var report in reports) + { + if (report.Machines == null) + report.Machines = new(); + } return View(reports); diff --git a/Factory/FactoryWorkerApp/Views/Home/PlanProductions.cshtml b/Factory/FactoryWorkerApp/Views/Home/PlanProductions.cshtml index e8e7349..49e36a3 100644 --- a/Factory/FactoryWorkerApp/Views/Home/PlanProductions.cshtml +++ b/Factory/FactoryWorkerApp/Views/Home/PlanProductions.cshtml @@ -14,7 +14,7 @@

Создать план - Привязка планов производства к заготовкам + Привязка заготовок к планам производства