From 97f9ef064e1db01e934e33e7ee0a42cab1535536 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 30 Apr 2024 22:39:32 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20CourseId=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C=20?= =?UTF-8?q?=D1=80=D0=B5=D1=86=D0=B5=D0=BF=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs b/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs index f912678..46a0d90 100644 --- a/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs +++ b/Polyclinic/PolyclinicDataModels/Models/IRecipeModel.cs @@ -4,6 +4,7 @@ { int ProceduresCount { get; set; } string Comment { get; set; } + int CourseId { get; set; } Dictionary RecipeProcedures { get; } } } \ No newline at end of file -- 2.25.1 From 452c558e21cc4e25d0f4bc6e9c32442f74aae389 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 30 Apr 2024 22:40:19 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20Reci?= =?UTF-8?q?peId=20=D0=B8=D0=B7=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BA=D1=83=D1=80=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Polyclinic/PolyclinicDataModels/Models/ICourseModel.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Polyclinic/PolyclinicDataModels/Models/ICourseModel.cs b/Polyclinic/PolyclinicDataModels/Models/ICourseModel.cs index 2ace9f7..152f061 100644 --- a/Polyclinic/PolyclinicDataModels/Models/ICourseModel.cs +++ b/Polyclinic/PolyclinicDataModels/Models/ICourseModel.cs @@ -5,7 +5,6 @@ int DaysCount { get; } int PillsPerDay { get; } string Comment { get; } - int RecipeId { get; } Dictionary CourseDiagnoses { get; } } } -- 2.25.1 From b3101ea16962c5f181c34891649c3169c7281026 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 30 Apr 2024 22:41:26 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=B8=D0=BD=D0=B4=D0=B8=D0=BD=D0=B3=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PolyclinicContracts/BindingModels/CourseBindingModel.cs | 1 - .../PolyclinicContracts/BindingModels/RecipeBindingModel.cs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyclinic/PolyclinicContracts/BindingModels/CourseBindingModel.cs b/Polyclinic/PolyclinicContracts/BindingModels/CourseBindingModel.cs index a6b7777..ccca0c5 100644 --- a/Polyclinic/PolyclinicContracts/BindingModels/CourseBindingModel.cs +++ b/Polyclinic/PolyclinicContracts/BindingModels/CourseBindingModel.cs @@ -7,7 +7,6 @@ namespace PolyclinicContracts.BindingModels public int DaysCount { get; set; } public int PillsPerDay { get; set; } public string Comment { get; set; } = string.Empty; - public int RecipeId { get; set; } public Dictionary CourseDiagnoses { get; set; } = new(); public int Id { get; set; } } diff --git a/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs b/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs index fdf120b..a8fb036 100644 --- a/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs +++ b/Polyclinic/PolyclinicContracts/BindingModels/RecipeBindingModel.cs @@ -5,6 +5,7 @@ namespace PolyclinicContracts.BindingModels public class RecipeBindingModel : IRecipeModel { public int Id { get; set; } + public int CourseId { get; set; } public int ProceduresCount { get; set; } public string Comment { get; set; } = string.Empty; public Dictionary RecipeProcedures { get; } = new(); -- 2.25.1 From 33ce1eb14b851ebbbd587fb9d701f559f4049684 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 30 Apr 2024 22:42:51 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20view=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Polyclinic/PolyclinicContracts/ViewModels/CourseViewModel.cs | 1 - Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Polyclinic/PolyclinicContracts/ViewModels/CourseViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/CourseViewModel.cs index 89fbc16..55eb5f1 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/CourseViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/CourseViewModel.cs @@ -11,7 +11,6 @@ namespace PolyclinicContracts.ViewModels public int PillsPerDay { get; set; } [DisplayName("Комментарий")] public string Comment { get; set; } = string.Empty; - public int RecipeId { get; set; } public Dictionary CourseDiagnoses { get; set; } = new(); public int Id { get; set; } } diff --git a/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs b/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs index b22d3b2..3aae688 100644 --- a/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs +++ b/Polyclinic/PolyclinicContracts/ViewModels/RecipeViewModel.cs @@ -12,7 +12,7 @@ namespace PolyclinicContracts.ViewModels [DisplayName("Комментарий")] public string Comment { get; set; } = string.Empty; - + public int CourseId { get; set; } public Dictionary RecipeProcedures { get; } = new(); } } -- 2.25.1 From 4297c5d6d0ddc771f2bbd34d8917b76a3736aeb0 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 30 Apr 2024 22:51:17 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B8=20=D0=B4=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B1=D0=B4=20=D0=B8=20=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/CourseStorage.cs | 1 - .../Implements/RecipeStorage.cs | 1 + ...> 20240430185032_InitDatabase.Designer.cs} | 36 ++-- ...eate.cs => 20240430185032_InitDatabase.cs} | 162 +++++++++--------- .../PolyclinicDatabaseModelSnapshot.cs | 32 ++-- .../Models/Course.cs | 6 - .../Models/Recipe.cs | 7 +- .../PolyclinicDatabaseImplement.csproj | 4 + .../PolyclinicWebAppImplementer.csproj | 11 ++ 9 files changed, 137 insertions(+), 123 deletions(-) rename Polyclinic/PolyclinicDatabaseImplement/Migrations/{20240430121818_InitCreate.Designer.cs => 20240430185032_InitDatabase.Designer.cs} (97%) rename Polyclinic/PolyclinicDatabaseImplement/Migrations/{20240430121818_InitCreate.cs => 20240430185032_InitDatabase.cs} (97%) diff --git a/Polyclinic/PolyclinicDatabaseImplement/Implements/CourseStorage.cs b/Polyclinic/PolyclinicDatabaseImplement/Implements/CourseStorage.cs index 80ba25e..fccc716 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Implements/CourseStorage.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Implements/CourseStorage.cs @@ -45,7 +45,6 @@ namespace PolyclinicDatabaseImplement.Implements { using var context = new PolyclinicDatabase(); return context.Courses - .Include(x => x.Recipe) .Include(x => x.Diagnoses) .ThenInclude(x => x.Diagnose) .Select(x => x.GetViewModel) diff --git a/Polyclinic/PolyclinicDatabaseImplement/Implements/RecipeStorage.cs b/Polyclinic/PolyclinicDatabaseImplement/Implements/RecipeStorage.cs index d3aa7a6..b2b0e4f 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Implements/RecipeStorage.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Implements/RecipeStorage.cs @@ -14,6 +14,7 @@ namespace PolyclinicDatabaseImplement.Implements { using var database = new PolyclinicDatabase(); return database.Recipes + .Include(x => x.Course) .Include(x => x.Procedures) .ThenInclude(x => x.Procedure) .Select(x => x.GetViewModel) diff --git a/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430121818_InitCreate.Designer.cs b/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430185032_InitDatabase.Designer.cs similarity index 97% rename from Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430121818_InitCreate.Designer.cs rename to Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430185032_InitDatabase.Designer.cs index 86163da..6f641fe 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430121818_InitCreate.Designer.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430185032_InitDatabase.Designer.cs @@ -11,8 +11,8 @@ using SecuritySystemDatabaseImplement; namespace PolyclinicDatabaseImplement.Migrations { [DbContext(typeof(PolyclinicDatabase))] - [Migration("20240430121818_InitCreate")] - partial class InitCreate + [Migration("20240430185032_InitDatabase")] + partial class InitDatabase { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -42,13 +42,8 @@ namespace PolyclinicDatabaseImplement.Migrations b.Property("PillsPerDay") .HasColumnType("int"); - b.Property("RecipeId") - .HasColumnType("int"); - b.HasKey("Id"); - b.HasIndex("RecipeId"); - b.ToTable("Courses"); }); @@ -168,11 +163,16 @@ namespace PolyclinicDatabaseImplement.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("CourseId") + .HasColumnType("int"); + b.Property("ProceduresCount") .HasColumnType("int"); b.HasKey("Id"); + b.HasIndex("CourseId"); + b.ToTable("Recipes"); }); @@ -294,17 +294,6 @@ namespace PolyclinicDatabaseImplement.Migrations b.ToTable("Users"); }); - modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Course", b => - { - b.HasOne("PolyclinicDatabaseImplement.Models.Recipe", "Recipe") - .WithMany() - .HasForeignKey("RecipeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Recipe"); - }); - modelBuilder.Entity("PolyclinicDatabaseImplement.Models.CourseDiagnose", b => { b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course") @@ -354,6 +343,17 @@ namespace PolyclinicDatabaseImplement.Migrations b.Navigation("Symptom"); }); + modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b => + { + b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + }); + modelBuilder.Entity("PolyclinicDatabaseImplement.Models.RecipeProcedure", b => { b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure") diff --git a/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430121818_InitCreate.cs b/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430185032_InitDatabase.cs similarity index 97% rename from Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430121818_InitCreate.cs rename to Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430185032_InitDatabase.cs index 1dd5edc..44b77cf 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430121818_InitCreate.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Migrations/20240430185032_InitDatabase.cs @@ -5,11 +5,26 @@ namespace PolyclinicDatabaseImplement.Migrations { /// - public partial class InitCreate : Migration + public partial class InitDatabase : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "Courses", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DaysCount = table.Column(type: "int", nullable: false), + PillsPerDay = table.Column(type: "int", nullable: false), + Comment = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Courses", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Procedures", columns: table => new @@ -25,20 +40,6 @@ namespace PolyclinicDatabaseImplement.Migrations table.PrimaryKey("PK_Procedures", x => x.Id); }); - migrationBuilder.CreateTable( - name: "Recipes", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ProceduresCount = table.Column(type: "int", nullable: false), - Comment = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Recipes", x => x.Id); - }); - migrationBuilder.CreateTable( name: "Symptomes", columns: table => new @@ -70,49 +71,22 @@ namespace PolyclinicDatabaseImplement.Migrations }); migrationBuilder.CreateTable( - name: "Courses", + name: "Recipes", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), - DaysCount = table.Column(type: "int", nullable: false), - PillsPerDay = table.Column(type: "int", nullable: false), + ProceduresCount = table.Column(type: "int", nullable: false), Comment = table.Column(type: "nvarchar(max)", nullable: false), - RecipeId = table.Column(type: "int", nullable: false) + CourseId = table.Column(type: "int", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Courses", x => x.Id); + table.PrimaryKey("PK_Recipes", x => x.Id); table.ForeignKey( - name: "FK_Courses_Recipes_RecipeId", - column: x => x.RecipeId, - principalTable: "Recipes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "RecipeProcedures", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ProcedureId = table.Column(type: "int", nullable: false), - RecipeId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_RecipeProcedures", x => x.Id); - table.ForeignKey( - name: "FK_RecipeProcedures_Procedures_ProcedureId", - column: x => x.ProcedureId, - principalTable: "Procedures", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_RecipeProcedures_Recipes_RecipeId", - column: x => x.RecipeId, - principalTable: "Recipes", + name: "FK_Recipes_Courses_CourseId", + column: x => x.CourseId, + principalTable: "Courses", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -145,6 +119,53 @@ namespace PolyclinicDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "Diagnoses", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Comment = table.Column(type: "nvarchar(max)", nullable: false), + UserId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Diagnoses", x => x.Id); + table.ForeignKey( + name: "FK_Diagnoses_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RecipeProcedures", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProcedureId = table.Column(type: "int", nullable: false), + RecipeId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RecipeProcedures", x => x.Id); + table.ForeignKey( + name: "FK_RecipeProcedures_Procedures_ProcedureId", + column: x => x.ProcedureId, + principalTable: "Procedures", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RecipeProcedures_Recipes_RecipeId", + column: x => x.RecipeId, + principalTable: "Recipes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "SymptomRecipes", columns: table => new @@ -171,27 +192,6 @@ namespace PolyclinicDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "Diagnoses", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Comment = table.Column(type: "nvarchar(max)", nullable: false), - UserId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Diagnoses", x => x.Id); - table.ForeignKey( - name: "FK_Diagnoses_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateTable( name: "CourseDiagnoses", columns: table => new @@ -254,11 +254,6 @@ namespace PolyclinicDatabaseImplement.Migrations table: "CourseDiagnoses", column: "DiagnoseId"); - migrationBuilder.CreateIndex( - name: "IX_Courses_RecipeId", - table: "Courses", - column: "RecipeId"); - migrationBuilder.CreateIndex( name: "IX_Diagnoses_UserId", table: "Diagnoses", @@ -284,6 +279,11 @@ namespace PolyclinicDatabaseImplement.Migrations table: "RecipeProcedures", column: "RecipeId"); + migrationBuilder.CreateIndex( + name: "IX_Recipes_CourseId", + table: "Recipes", + column: "CourseId"); + migrationBuilder.CreateIndex( name: "IX_SymptomDiagnoses_DiagnoseId", table: "SymptomDiagnoses", @@ -323,23 +323,23 @@ namespace PolyclinicDatabaseImplement.Migrations migrationBuilder.DropTable( name: "SymptomRecipes"); - migrationBuilder.DropTable( - name: "Courses"); - migrationBuilder.DropTable( name: "Procedures"); migrationBuilder.DropTable( name: "Diagnoses"); - migrationBuilder.DropTable( - name: "Symptomes"); - migrationBuilder.DropTable( name: "Recipes"); + migrationBuilder.DropTable( + name: "Symptomes"); + migrationBuilder.DropTable( name: "Users"); + + migrationBuilder.DropTable( + name: "Courses"); } } } diff --git a/Polyclinic/PolyclinicDatabaseImplement/Migrations/PolyclinicDatabaseModelSnapshot.cs b/Polyclinic/PolyclinicDatabaseImplement/Migrations/PolyclinicDatabaseModelSnapshot.cs index 5066c49..a4e4364 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Migrations/PolyclinicDatabaseModelSnapshot.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Migrations/PolyclinicDatabaseModelSnapshot.cs @@ -39,13 +39,8 @@ namespace PolyclinicDatabaseImplement.Migrations b.Property("PillsPerDay") .HasColumnType("int"); - b.Property("RecipeId") - .HasColumnType("int"); - b.HasKey("Id"); - b.HasIndex("RecipeId"); - b.ToTable("Courses"); }); @@ -165,11 +160,16 @@ namespace PolyclinicDatabaseImplement.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("CourseId") + .HasColumnType("int"); + b.Property("ProceduresCount") .HasColumnType("int"); b.HasKey("Id"); + b.HasIndex("CourseId"); + b.ToTable("Recipes"); }); @@ -291,17 +291,6 @@ namespace PolyclinicDatabaseImplement.Migrations b.ToTable("Users"); }); - modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Course", b => - { - b.HasOne("PolyclinicDatabaseImplement.Models.Recipe", "Recipe") - .WithMany() - .HasForeignKey("RecipeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Recipe"); - }); - modelBuilder.Entity("PolyclinicDatabaseImplement.Models.CourseDiagnose", b => { b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course") @@ -351,6 +340,17 @@ namespace PolyclinicDatabaseImplement.Migrations b.Navigation("Symptom"); }); + modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b => + { + b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course") + .WithMany() + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + }); + modelBuilder.Entity("PolyclinicDatabaseImplement.Models.RecipeProcedure", b => { b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure") diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/Course.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/Course.cs index ec7c262..59bd410 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/Course.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/Course.cs @@ -15,9 +15,6 @@ namespace PolyclinicDatabaseImplement.Models [Required] public int PillsPerDay { get; set; } public string Comment { get; set; } = string.Empty; - [Required] - public int RecipeId { get; set; } - public virtual Recipe Recipe { get; set; } = new(); [ForeignKey("CourseId")] public virtual List Diagnoses { get; set; } = new(); private Dictionary? _courseDiagnoses = null; @@ -45,7 +42,6 @@ namespace PolyclinicDatabaseImplement.Models DaysCount = model.DaysCount, PillsPerDay = model.PillsPerDay, Comment = model.Comment, - RecipeId = model.RecipeId, Diagnoses = model.CourseDiagnoses.Select(courseDiagnose => new CourseDiagnose { Diagnose = context.Diagnoses.First(diagnose => diagnose.Id == courseDiagnose.Key) @@ -58,7 +54,6 @@ namespace PolyclinicDatabaseImplement.Models DaysCount = model.DaysCount; PillsPerDay = model.PillsPerDay; Comment = model.Comment; - RecipeId = model.RecipeId; } public CourseViewModel GetViewModel => new() @@ -67,7 +62,6 @@ namespace PolyclinicDatabaseImplement.Models DaysCount = DaysCount, PillsPerDay = PillsPerDay, Comment = Comment, - RecipeId = RecipeId, CourseDiagnoses = CourseDiagnoses }; diff --git a/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs b/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs index e04a34c..87c0761 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs +++ b/Polyclinic/PolyclinicDatabaseImplement/Models/Recipe.cs @@ -16,6 +16,8 @@ namespace PolyclinicDatabaseImplement.Models [Required] public string Comment { get; set; } = string.Empty; + public int CourseId { get; set; } + public virtual Course Course { get; set; } = new(); private Dictionary? _recipeProcedures = null; @@ -42,6 +44,7 @@ namespace PolyclinicDatabaseImplement.Models Id = bindingModel.Id, ProceduresCount = bindingModel.ProceduresCount, Comment = bindingModel.Comment, + CourseId = bindingModel.CourseId, Procedures = bindingModel.RecipeProcedures.Select(x => new RecipeProcedure { Recipe = database.Recipes.First(y => y.Id == x.Key) @@ -53,13 +56,15 @@ namespace PolyclinicDatabaseImplement.Models { ProceduresCount = bindingModel.ProceduresCount; Comment = bindingModel.Comment; + CourseId = bindingModel.CourseId; } public RecipeViewModel GetViewModel => new() { Id = Id, ProceduresCount = ProceduresCount, - Comment = Comment + Comment = Comment, + CourseId = CourseId, }; public void UpdateProcedures(PolyclinicDatabase database, RecipeBindingModel bindingModel) diff --git a/Polyclinic/PolyclinicDatabaseImplement/PolyclinicDatabaseImplement.csproj b/Polyclinic/PolyclinicDatabaseImplement/PolyclinicDatabaseImplement.csproj index a1d7582..6a1d280 100644 --- a/Polyclinic/PolyclinicDatabaseImplement/PolyclinicDatabaseImplement.csproj +++ b/Polyclinic/PolyclinicDatabaseImplement/PolyclinicDatabaseImplement.csproj @@ -20,4 +20,8 @@ + + + + diff --git a/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj b/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj index 4c34883..d723787 100644 --- a/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj +++ b/Polyclinic/PolyclinicWebAppImplementer/PolyclinicWebAppImplementer.csproj @@ -42,4 +42,15 @@ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + -- 2.25.1