diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs index 2097505..8498fa9 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs @@ -1,4 +1,6 @@ -using FactoryContracts.BindingModels; +using FactoryBusinessLogic.OfficePackage; +using FactoryBusinessLogic.OfficePackage.HelperModels; +using FactoryContracts.BindingModels; using FactoryContracts.BusinessLogicsContracts; using FactoryContracts.SearchModels; using FactoryContracts.StoragesContracts; @@ -10,30 +12,54 @@ namespace FactoryBusinessLogic.BusinessLogics { private readonly IMachineStorage _machineStorage; private readonly IProductStorage _productStorage; - public StorekeeperReportLogic(IMachineStorage machineStorage, IProductStorage productStorage) + private readonly AbstractSaveToWord _saveToWord; + private readonly AbstractSaveToExcel _saveToExcel; + private readonly AbstractSaveToPdf _saveToPdf; + public StorekeeperReportLogic(IMachineStorage machineStorage, IProductStorage productStorage, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel, AbstractSaveToPdf saveToPdf) + { + _machineStorage = machineStorage; + _productStorage = productStorage; + _saveToWord = saveToWord; + _saveToExcel = saveToExcel; + _saveToPdf = saveToPdf; + } + public List GetPlanProductionsByProduct(List products) { - _machineStorage = machineStorage; - _productStorage = productStorage; - } - public List GetPlanProductionsByProduct(List products) - { - return _productStorage.GetPlanProductions(products); + List ids = products.Select(x => (int)x.Id).ToList(); + return _productStorage.GetPlanProductions(ids); } public List GetMachines(ClientSearchModel client, ReportBindingModel model) { return _machineStorage.GetMachinesByPeriod(client, model); } - public void SaveMachinesToPdfFile(ReportBindingModel model) + public void SaveMachinesToPdfFile(ClientSearchModel client, ReportBindingModel model) { - throw new NotImplementedException(); + _saveToPdf.CreateStorekeeperDoc(new StorekeeperPdfInfo + { + FileName = model.FileName, + Title = "Список станков", + DateFrom = model.DateFrom!.Value, + DateTo = model.DateTo!.Value, + Machines = GetMachines(client, model) + }); } - public void SavePlanProductionsToExcelFile(ReportBindingModel model) + public void SavePlanProductionsToExcelFile(ReportBindingModel model, List products) { - throw new NotImplementedException(); + _saveToExcel.CreateStorekeeperReport(new StorekeeperExcelInfo + { + FileName = model.FileName, + Title = "Список планов производств", + ProductPlanProductions = GetPlanProductionsByProduct(products) + }); } - public void SavePlanProductionsToWordFile(ReportBindingModel model) + public void SavePlanProductionsToWordFile(ReportBindingModel model, List products) { - throw new NotImplementedException(); - } + _saveToWord.CreateStorekeeperDoc(new StorekeeperWordInfo + { + FileName = model.FileName, + Title = "Список планов производств", + ProductPlanProductions = GetPlanProductionsByProduct(products) + }); + } } } diff --git a/Factory/FactoryContracts/BusinessLogicsContracts/IStorekeeperReportLogic.cs b/Factory/FactoryContracts/BusinessLogicsContracts/IStorekeeperReportLogic.cs index c3ad560..36f3969 100644 --- a/Factory/FactoryContracts/BusinessLogicsContracts/IStorekeeperReportLogic.cs +++ b/Factory/FactoryContracts/BusinessLogicsContracts/IStorekeeperReportLogic.cs @@ -8,8 +8,8 @@ namespace FactoryContracts.BusinessLogicsContracts { List GetPlanProductionsByProduct(List products); List GetMachines(ClientSearchModel client, ReportBindingModel model); - void SavePlanProductionsToWordFile(ReportBindingModel model); - void SavePlanProductionsToExcelFile(ReportBindingModel model); - void SaveMachinesToPdfFile(ReportBindingModel model); + void SavePlanProductionsToWordFile(ReportBindingModel model, List products); + void SavePlanProductionsToExcelFile(ReportBindingModel model, List products); + void SaveMachinesToPdfFile(ClientSearchModel client, ReportBindingModel model); } } diff --git a/Factory/FactoryContracts/SearchModels/ClientSearchModel.cs b/Factory/FactoryContracts/SearchModels/ClientSearchModel.cs index f130500..c8f4af0 100644 --- a/Factory/FactoryContracts/SearchModels/ClientSearchModel.cs +++ b/Factory/FactoryContracts/SearchModels/ClientSearchModel.cs @@ -1,4 +1,6 @@ -namespace FactoryContracts.SearchModels +using FactoryDataModels.Enums; + +namespace FactoryContracts.SearchModels { public class ClientSearchModel { @@ -7,5 +9,7 @@ public string? Login { get; set; } public string? Password { get; set; } + + public ClientRole? Role { get; set; } } } \ No newline at end of file diff --git a/Factory/FactoryContracts/StoragesContracts/IProductStorage.cs b/Factory/FactoryContracts/StoragesContracts/IProductStorage.cs index 421058a..eddb2fe 100644 --- a/Factory/FactoryContracts/StoragesContracts/IProductStorage.cs +++ b/Factory/FactoryContracts/StoragesContracts/IProductStorage.cs @@ -18,6 +18,6 @@ namespace FactoryContracts.StoragesContracts ProductViewModel? Delete(ProductBindingModel model); - List GetPlanProductions(List products); + List GetPlanProductions(List ids); } } diff --git a/Factory/FactoryDatabaseImplement/Implements/ProductStorage.cs b/Factory/FactoryDatabaseImplement/Implements/ProductStorage.cs index e2cc9f2..0edd483 100644 --- a/Factory/FactoryDatabaseImplement/Implements/ProductStorage.cs +++ b/Factory/FactoryDatabaseImplement/Implements/ProductStorage.cs @@ -112,27 +112,19 @@ namespace FactoryDatabaseImplement.Implements return null; } - public List GetPlanProductions(List products) + public List GetPlanProductions(List ids) { using var context = new FactoryDatabase(); - // not sure if it works return context.Products - .Include(x => x.Client) - .Include(x => x.Machines) - .ThenInclude(x => x.Machine) - .Where(x => products.Any(y => x.ProductName == y.ProductName && x.ClientId == y.ClientId)) - .Select(x => new ProductPlanProductionReportViewModel() + .Where(prod => ids.Contains(prod.Id)) + .Select(prod => new ProductPlanProductionReportViewModel() { - ProductName = x.ProductName, - PlanProductions = context.PlanProductions - .Include(y => y.Workpieces). - ThenInclude(y => y.Workpiece) - .ThenInclude(y => y.Products) - .ThenInclude(y => y.Product) - .Where(y => y.Workpieces.Any(z => z.Workpiece.Products.Any(v => v.Product.ProductName == x.ProductName))) - .Select(y => y.GetViewModel) - .ToList() - + ProductName = prod.ProductName, + PlanProductions = context.PlanProductionWorkpieces + .Include(x => x.PlanProduction) + .Where(plan => prod.Id == plan.PlanProduction.Id) + .Select(x => x.PlanProduction.GetViewModel) + .ToList(), }) .ToList(); } diff --git a/Factory/FactoryDatabaseImplement/Migrations/20240528135247_InitCreate.Designer.cs b/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.Designer.cs similarity index 96% rename from Factory/FactoryDatabaseImplement/Migrations/20240528135247_InitCreate.Designer.cs rename to Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.Designer.cs index bd2c66e..2ca0020 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/20240528135247_InitCreate.Designer.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace FactoryDatabaseImplement.Migrations { [DbContext(typeof(FactoryDatabase))] - [Migration("20240528135247_InitCreate")] + [Migration("20240528144223_InitCreate")] partial class InitCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -81,7 +81,8 @@ namespace FactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("PlanProductionId"); + b.HasIndex("PlanProductionId") + .IsUnique(); b.ToTable("ExecutionPhases"); }); @@ -157,9 +158,6 @@ namespace FactoryDatabaseImplement.Migrations b.Property("Deadline") .HasColumnType("timestamp without time zone"); - b.Property("ExecutionPhaseId") - .HasColumnType("integer"); - b.Property("ProductionName") .IsRequired() .HasColumnType("text"); @@ -168,8 +166,6 @@ namespace FactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("ExecutionPhaseId"); - b.ToTable("PlanProductions"); }); @@ -349,8 +345,8 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired(); b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction") - .WithMany() - .HasForeignKey("PlanProductionId") + .WithOne("ExecutionPhase") + .HasForeignKey("FactoryDatabaseImplement.Models.ExecutionPhase", "PlanProductionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -397,10 +393,6 @@ namespace FactoryDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("FactoryDatabaseImplement.Models.ExecutionPhase", null) - .WithMany("PlanProductions") - .HasForeignKey("ExecutionPhaseId"); - b.Navigation("Client"); }); @@ -517,11 +509,6 @@ namespace FactoryDatabaseImplement.Migrations b.Navigation("Workpieces"); }); - modelBuilder.Entity("FactoryDatabaseImplement.Models.ExecutionPhase", b => - { - b.Navigation("PlanProductions"); - }); - modelBuilder.Entity("FactoryDatabaseImplement.Models.Machine", b => { b.Navigation("PlanProductions"); @@ -531,6 +518,9 @@ 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/20240528135247_InitCreate.cs b/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.cs similarity index 92% rename from Factory/FactoryDatabaseImplement/Migrations/20240528135247_InitCreate.cs rename to Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.cs index c7afc39..0bfa318 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/20240528135247_InitCreate.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/20240528144223_InitCreate.cs @@ -48,6 +48,28 @@ namespace FactoryDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "PlanProductions", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ClientId = table.Column(type: "integer", nullable: false), + ProductionName = table.Column(type: "text", nullable: false), + Count = table.Column(type: "integer", nullable: false), + Deadline = table.Column(type: "timestamp without time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PlanProductions", x => x.Id); + table.ForeignKey( + name: "FK_PlanProductions_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Products", columns: table => new @@ -92,6 +114,62 @@ namespace FactoryDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "ExecutionPhases", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ClientId = table.Column(type: "integer", nullable: false), + PlanProductionId = table.Column(type: "integer", nullable: false), + ExecutionPhaseName = table.Column(type: "text", nullable: false), + ImplementerFIO = table.Column(type: "text", nullable: false), + Status = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ExecutionPhases", x => x.Id); + table.ForeignKey( + name: "FK_ExecutionPhases_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ExecutionPhases_PlanProductions_PlanProductionId", + column: x => x.PlanProductionId, + principalTable: "PlanProductions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MachinePlanProductions", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + MachineId = table.Column(type: "integer", nullable: false), + PlanProductionId = table.Column(type: "integer", nullable: false), + Count = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MachinePlanProductions", x => x.Id); + table.ForeignKey( + name: "FK_MachinePlanProductions_Machines_MachineId", + column: x => x.MachineId, + principalTable: "Machines", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_MachinePlanProductions_PlanProductions_PlanProductionId", + column: x => x.PlanProductionId, + principalTable: "PlanProductions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "ProductMachines", columns: table => new @@ -147,111 +225,6 @@ namespace FactoryDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "WorkpieceProducts", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - WorkpieceId = table.Column(type: "integer", nullable: false), - ProductId = table.Column(type: "integer", nullable: false), - Count = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_WorkpieceProducts", x => x.Id); - table.ForeignKey( - name: "FK_WorkpieceProducts_Products_ProductId", - column: x => x.ProductId, - principalTable: "Products", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_WorkpieceProducts_Workpieces_WorkpieceId", - column: x => x.WorkpieceId, - principalTable: "Workpieces", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ExecutionPhases", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ClientId = table.Column(type: "integer", nullable: false), - PlanProductionId = table.Column(type: "integer", nullable: false), - ExecutionPhaseName = table.Column(type: "text", nullable: false), - ImplementerFIO = table.Column(type: "text", nullable: false), - Status = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ExecutionPhases", x => x.Id); - table.ForeignKey( - name: "FK_ExecutionPhases_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "PlanProductions", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ClientId = table.Column(type: "integer", nullable: false), - ProductionName = table.Column(type: "text", nullable: false), - Count = table.Column(type: "integer", nullable: false), - Deadline = table.Column(type: "timestamp without time zone", nullable: false), - ExecutionPhaseId = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_PlanProductions", x => x.Id); - table.ForeignKey( - name: "FK_PlanProductions_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_PlanProductions_ExecutionPhases_ExecutionPhaseId", - column: x => x.ExecutionPhaseId, - principalTable: "ExecutionPhases", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "MachinePlanProductions", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - MachineId = table.Column(type: "integer", nullable: false), - PlanProductionId = table.Column(type: "integer", nullable: false), - Count = table.Column(type: "integer", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_MachinePlanProductions", x => x.Id); - table.ForeignKey( - name: "FK_MachinePlanProductions_Machines_MachineId", - column: x => x.MachineId, - principalTable: "Machines", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_MachinePlanProductions_PlanProductions_PlanProductionId", - column: x => x.PlanProductionId, - principalTable: "PlanProductions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "PlanProductionWorkpieces", columns: table => new @@ -279,6 +252,33 @@ namespace FactoryDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "WorkpieceProducts", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + WorkpieceId = table.Column(type: "integer", nullable: false), + ProductId = table.Column(type: "integer", nullable: false), + Count = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkpieceProducts", x => x.Id); + table.ForeignKey( + name: "FK_WorkpieceProducts_Products_ProductId", + column: x => x.ProductId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_WorkpieceProducts_Workpieces_WorkpieceId", + column: x => x.WorkpieceId, + principalTable: "Workpieces", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_ExecutionPhases_ClientId", table: "ExecutionPhases", @@ -287,7 +287,8 @@ namespace FactoryDatabaseImplement.Migrations migrationBuilder.CreateIndex( name: "IX_ExecutionPhases_PlanProductionId", table: "ExecutionPhases", - column: "PlanProductionId"); + column: "PlanProductionId", + unique: true); migrationBuilder.CreateIndex( name: "IX_MachinePlanProductions_MachineId", @@ -309,11 +310,6 @@ namespace FactoryDatabaseImplement.Migrations table: "PlanProductions", column: "ClientId"); - migrationBuilder.CreateIndex( - name: "IX_PlanProductions_ExecutionPhaseId", - table: "PlanProductions", - column: "ExecutionPhaseId"); - migrationBuilder.CreateIndex( name: "IX_PlanProductionWorkpieces_PlanProductionId", table: "PlanProductionWorkpieces", @@ -364,29 +360,12 @@ namespace FactoryDatabaseImplement.Migrations name: "IX_Workpieces_ClientId", table: "Workpieces", column: "ClientId"); - - migrationBuilder.AddForeignKey( - name: "FK_ExecutionPhases_PlanProductions_PlanProductionId", - table: "ExecutionPhases", - column: "PlanProductionId", - principalTable: "PlanProductions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); } protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DropForeignKey( - name: "FK_ExecutionPhases_Clients_ClientId", - table: "ExecutionPhases"); - - migrationBuilder.DropForeignKey( - name: "FK_PlanProductions_Clients_ClientId", - table: "PlanProductions"); - - migrationBuilder.DropForeignKey( - name: "FK_ExecutionPhases_PlanProductions_PlanProductionId", - table: "ExecutionPhases"); + migrationBuilder.DropTable( + name: "ExecutionPhases"); migrationBuilder.DropTable( name: "MachinePlanProductions"); @@ -403,6 +382,9 @@ namespace FactoryDatabaseImplement.Migrations migrationBuilder.DropTable( name: "WorkpieceProducts"); + migrationBuilder.DropTable( + name: "PlanProductions"); + migrationBuilder.DropTable( name: "Machines"); @@ -414,12 +396,6 @@ namespace FactoryDatabaseImplement.Migrations migrationBuilder.DropTable( name: "Clients"); - - migrationBuilder.DropTable( - name: "PlanProductions"); - - migrationBuilder.DropTable( - name: "ExecutionPhases"); } } } diff --git a/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs b/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs index 9e898ef..b06323e 100644 --- a/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs +++ b/Factory/FactoryDatabaseImplement/Migrations/FactoryDatabaseModelSnapshot.cs @@ -79,7 +79,8 @@ namespace FactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("PlanProductionId"); + b.HasIndex("PlanProductionId") + .IsUnique(); b.ToTable("ExecutionPhases"); }); @@ -155,9 +156,6 @@ namespace FactoryDatabaseImplement.Migrations b.Property("Deadline") .HasColumnType("timestamp without time zone"); - b.Property("ExecutionPhaseId") - .HasColumnType("integer"); - b.Property("ProductionName") .IsRequired() .HasColumnType("text"); @@ -166,8 +164,6 @@ namespace FactoryDatabaseImplement.Migrations b.HasIndex("ClientId"); - b.HasIndex("ExecutionPhaseId"); - b.ToTable("PlanProductions"); }); @@ -347,8 +343,8 @@ namespace FactoryDatabaseImplement.Migrations .IsRequired(); b.HasOne("FactoryDatabaseImplement.Models.PlanProduction", "PlanProduction") - .WithMany() - .HasForeignKey("PlanProductionId") + .WithOne("ExecutionPhase") + .HasForeignKey("FactoryDatabaseImplement.Models.ExecutionPhase", "PlanProductionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -395,10 +391,6 @@ namespace FactoryDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("FactoryDatabaseImplement.Models.ExecutionPhase", null) - .WithMany("PlanProductions") - .HasForeignKey("ExecutionPhaseId"); - b.Navigation("Client"); }); @@ -515,11 +507,6 @@ namespace FactoryDatabaseImplement.Migrations b.Navigation("Workpieces"); }); - modelBuilder.Entity("FactoryDatabaseImplement.Models.ExecutionPhase", b => - { - b.Navigation("PlanProductions"); - }); - modelBuilder.Entity("FactoryDatabaseImplement.Models.Machine", b => { b.Navigation("PlanProductions"); @@ -529,6 +516,9 @@ namespace FactoryDatabaseImplement.Migrations modelBuilder.Entity("FactoryDatabaseImplement.Models.PlanProduction", b => { + b.Navigation("ExecutionPhase") + .IsRequired(); + b.Navigation("Machines"); b.Navigation("Workpieces"); diff --git a/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs b/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs index 0c6a232..4e5c633 100644 --- a/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs +++ b/Factory/FactoryDatabaseImplement/Models/ExecutionPhase.cs @@ -16,18 +16,15 @@ namespace FactoryDatabaseImplement.Models [Required] public int PlanProductionId { get; private set; } - public virtual PlanProduction PlanProduction { get; private set; } + public virtual PlanProduction PlanProduction { get; private set; } = null!; - [Required] + [Required] public string ExecutionPhaseName { get; private set; } = string.Empty; [Required] public string ImplementerFIO { get; private set; } = string.Empty; [Required] public ExecutionPhaseStatus Status { get; private set; } = ExecutionPhaseStatus.Неизвестен; - [ForeignKey("ExecutionPhaseId")] - public virtual List PlanProductions { get; set; } = new(); - public static ExecutionPhase? Create(ExecutionPhaseBindingModel model) { if (model == null) diff --git a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs index 8724c3f..00947f4 100644 --- a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs +++ b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs @@ -57,7 +57,7 @@ namespace FactoryStorekeeperApp.Controllers [HttpPost] public IActionResult Enter(string login, string password) { - var existsClient = clientLogic.ReadElement(new ClientSearchModel { Login = login, Password = password }); + var existsClient = clientLogic.ReadElement(new ClientSearchModel { Login = login, Password = password, Role = ClientRole.Кладовщик }); if (existsClient != null) {