From 884aef7a19482fc3043d0095964313fdccd65646 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Tue, 30 Apr 2024 22:42:25 +0400 Subject: [PATCH 1/2] Add README file --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 86d30b2..bac8b91 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # Coursach +Курсовая работа студентов группы ПИбд-21 Козырева Сергея и Блохина Дмитрия. +Вариант 10.3 + 10.4. Завод "Иди работать" Исполнитель + Поручитель \ No newline at end of file From 571fc1da8f3ea694e55fe15068a6112ac9c55591 Mon Sep 17 00:00:00 2001 From: Sergey Kozyrev Date: Tue, 30 Apr 2024 23:02:06 +0400 Subject: [PATCH 2/2] Production fix --- .../DatabaseImplement/Models/DetailProduction.cs | 1 - Course/DatabaseImplement/Models/Production.cs | 2 +- Course/TestingDatabase/Program.cs | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Course/DatabaseImplement/Models/DetailProduction.cs b/Course/DatabaseImplement/Models/DetailProduction.cs index b9f1d55..c34b6e7 100644 --- a/Course/DatabaseImplement/Models/DetailProduction.cs +++ b/Course/DatabaseImplement/Models/DetailProduction.cs @@ -14,7 +14,6 @@ namespace DatabaseImplement.Models public int DetailId { get; set; } [Required] public int ProductionId { get; set; } - public virtual Detail Detail { get; set; } = new(); public virtual Production Production { get; set; } = new(); } diff --git a/Course/DatabaseImplement/Models/Production.cs b/Course/DatabaseImplement/Models/Production.cs index 86e83db..d17631b 100644 --- a/Course/DatabaseImplement/Models/Production.cs +++ b/Course/DatabaseImplement/Models/Production.cs @@ -68,7 +68,7 @@ namespace DatabaseImplement.Models var productionDetails = context.DetailProductions.Where(rec => rec.ProductionId == model.Id).ToList(); if (productionDetails != null && productionDetails.Count > 0) { - context.DetailProductions.RemoveRange(productionDetails.Where(rec => model.ProductionDetails.ContainsKey(rec.ProductionId))); + context.DetailProductions.RemoveRange(productionDetails.Where(rec => !model.ProductionDetails.ContainsKey(rec.ProductionId))); context.SaveChanges(); } var production = context.Productions.First(x => x.Id == model.Id); diff --git a/Course/TestingDatabase/Program.cs b/Course/TestingDatabase/Program.cs index 45e0f61..a5e73ae 100644 --- a/Course/TestingDatabase/Program.cs +++ b/Course/TestingDatabase/Program.cs @@ -14,3 +14,17 @@ ProductionStorage productionionStorage = new ProductionStorage(); ProductStorage productStorage = new ProductStorage(); MachineStorage machineStorage = new MachineStorage(); GuarantorStorage guarantorStorage = new GuarantorStorage(); + + +productionionStorage.Update(new() +{ + Id = 4, + Name = "name", + Cost = 1, + UserId = 1, + ProductionDetails = new() + { + {1, detailStorage.GetElement(new() { Id = 1 }) }, + {3, detailStorage.GetElement(new() { Id = 3 }) } + } +}); \ No newline at end of file