From 6d28d04af6abfebc829bdb2e2beeed976a23d932 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sat, 20 May 2023 07:57:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F:=20=D1=80=D0=B5=D1=86=D0=B5=D0=BF?= =?UTF-8?q?=D1=82,=20=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OfficePackage/AbstractSaveToExcel.cs | 2 +- .../OfficePackage/AbstractSaveToWord.cs | 2 +- Hospital/HospitalDatabaseImplement/Models/Recipe.cs | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 2c8af81..49cebb4 100644 --- a/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -89,7 +89,7 @@ namespace HospitalBusinessLogic.OfficePackage { ColumnName = "E", RowIndex = rowIndex, - Text = patient.Item4.ToString(), + Text = patient.Item4.ToShortDateString(), StyleInfo = ExcelStyleInfoType.TextWithBroder }); rowIndex++; diff --git a/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 6ac408a..0f90169 100644 --- a/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Hospital/HospitalBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -35,7 +35,7 @@ namespace HospitalBusinessLogic.OfficePackage Texts = new List<(string, WordTextProperties)> { (patient.Item1, new WordTextProperties { Size = "24"}), (" " + patient.Item2, new WordTextProperties { Size = "24", }), - (" " + patient.Item3, new WordTextProperties { Size = "24", }), (", " + patient.Item4, new WordTextProperties { Size = "24", }) }, + (" " + patient.Item3, new WordTextProperties { Size = "24", }), (", " + patient.Item4.ToShortDateString(), new WordTextProperties { Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", diff --git a/Hospital/HospitalDatabaseImplement/Models/Recipe.cs b/Hospital/HospitalDatabaseImplement/Models/Recipe.cs index 2eb4847..27549fc 100644 --- a/Hospital/HospitalDatabaseImplement/Models/Recipe.cs +++ b/Hospital/HospitalDatabaseImplement/Models/Recipe.cs @@ -131,13 +131,18 @@ namespace HospitalDatabaseImplement.Models context.SaveChanges(); } var recipe = context.Recipes.First(x => x.Id == Id); + var existingTreatmentsIds = recipeTreatments?.Select(x => x.TreatmentId).ToList(); foreach (var rec in model.RecipeTreatments) { - context.RecipeTreatments.Add(new RecipeTreatment + if (existingTreatmentsIds != null && !existingTreatmentsIds.Contains(rec.Key)) + { + context.RecipeTreatments.Add(new RecipeTreatment { Recipe = recipe, Treatment = context.Treatments.First(x => x.Id == rec.Key), - }); + }); + } + context.SaveChanges(); } _recipeTreatments = null;