diff --git a/Hospital/Hospital.sln b/Hospital/Hospital.sln index db1016e..901d387 100644 --- a/Hospital/Hospital.sln +++ b/Hospital/Hospital.sln @@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDatabaseImplement", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalBusinessLogics", "HospitalBusinessLogics\HospitalBusinessLogics.csproj", "{1A20292D-5690-4C8A-859E-9CC72F0AACB5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalWebApp", "HospitalWebApp\HospitalWebApp.csproj", "{024326F5-A7A5-41B5-9BEB-C1B10A533F23}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalWebApp", "HospitalWebApp\HospitalWebApp.csproj", "{024326F5-A7A5-41B5-9BEB-C1B10A533F23}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HospitalRestApi", "HospitalRestApi\HospitalRestApi.csproj", "{D2449DB4-C819-44F4-8266-4B46CD8F15E2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {024326F5-A7A5-41B5-9BEB-C1B10A533F23}.Debug|Any CPU.Build.0 = Debug|Any CPU {024326F5-A7A5-41B5-9BEB-C1B10A533F23}.Release|Any CPU.ActiveCfg = Release|Any CPU {024326F5-A7A5-41B5-9BEB-C1B10A533F23}.Release|Any CPU.Build.0 = Release|Any CPU + {D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D2449DB4-C819-44F4-8266-4B46CD8F15E2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Hospital/HospitalBusinessLogics/OfficePackage/AbstractSaveToPdf.cs b/Hospital/HospitalBusinessLogics/OfficePackage/AbstractSaveToPdf.cs index fc03766..5b15209 100644 --- a/Hospital/HospitalBusinessLogics/OfficePackage/AbstractSaveToPdf.cs +++ b/Hospital/HospitalBusinessLogics/OfficePackage/AbstractSaveToPdf.cs @@ -1,5 +1,6 @@ using HospitalBusinessLogics.OfficePackage.HelperEnums; using HospitalBusinessLogics.OfficePackage.HelperModels; +using HospitalContracts.ViewModels; using System; using System.Collections.Generic; using System.Linq; @@ -56,18 +57,22 @@ namespace HospitalBusinessLogics.OfficePackage // Записываем имя пациента в первую колонку CreateRow(new PdfRowParameters { - Texts= new List { view.Patient.FullName, "", "" }, + Texts = new List { view.Patient.FullName, "", "" }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); + // Конвертируем из HashSet в List, чтобы можно было обращаться по индексу + List medicines = new List(view.Medicines); + List diseases = new List(view.Diseases); + // Записываем названия лекарств во 2 колонку // и названия лекарств в 3 колонку - int maxLength = Math.Max(view.Medicines.Count, view.Diseases.Count); + int maxLength = Math.Max(medicines.Count, diseases.Count); for (int i = 0; i < maxLength; i++) { - string medicine = (i < view.Medicines.Count) ? view.Medicines[i].Name : ""; - string disease = (i < view.Diseases.Count) ? view.Diseases[i].Name : ""; + string medicine = (i < medicines.Count) ? medicines[i].Name : ""; + string disease = (i < diseases.Count) ? diseases[i].Name : ""; CreateRow(new PdfRowParameters { Texts = new List { "", medicine, disease }, diff --git a/Hospital/HospitalDatabaseImplement/Migrations/20240430143203_InitCreate.Designer.cs b/Hospital/HospitalDatabaseImplement/Migrations/20240430143203_InitCreate.Designer.cs new file mode 100644 index 0000000..98a4e95 --- /dev/null +++ b/Hospital/HospitalDatabaseImplement/Migrations/20240430143203_InitCreate.Designer.cs @@ -0,0 +1,402 @@ +// +using System; +using HospitalDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace HospitalDatabaseImplement.Migrations +{ + [DbContext(typeof(HospitalDatabase))] + [Migration("20240430143203_InitCreate")] + partial class InitCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.13") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("Symptoms") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("RecipeId"); + + b.ToTable("Diseases"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Post") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Doctors"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.ToTable("Medicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("DoctorId") + .HasColumnType("int"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b.HasKey("Id"); + + b.HasIndex("DoctorId"); + + b.ToTable("Patients"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PatientId") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PatientId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("PatientProcedures"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PatientId") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PatientId"); + + b.HasIndex("RecipeId"); + + b.ToTable("PatientRecipes"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.ToTable("Procedures"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MedicineId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("ProcedureMedicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DoctorId") + .HasColumnType("int"); + + b.Property("IssueDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("DoctorId"); + + b.ToTable("Recipes"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MedicineId"); + + b.HasIndex("RecipeId"); + + b.ToTable("RecipeMedicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Recipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor") + .WithMany() + .HasForeignKey("DoctorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Doctor"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient") + .WithMany("Procedures") + .HasForeignKey("PatientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Patient"); + + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient") + .WithMany("Recipes") + .HasForeignKey("PatientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Recipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Patient"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") + .WithMany() + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure") + .WithMany("Medicines") + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medicine"); + + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor") + .WithMany() + .HasForeignKey("DoctorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Doctor"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") + .WithMany() + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Recipe", "Recipe") + .WithMany("Medicines") + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medicine"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => + { + b.Navigation("Procedures"); + + b.Navigation("Recipes"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b => + { + b.Navigation("Medicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b => + { + b.Navigation("Medicines"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hospital/HospitalDatabaseImplement/Migrations/20240430143203_InitCreate.cs b/Hospital/HospitalDatabaseImplement/Migrations/20240430143203_InitCreate.cs new file mode 100644 index 0000000..de6bb14 --- /dev/null +++ b/Hospital/HospitalDatabaseImplement/Migrations/20240430143203_InitCreate.cs @@ -0,0 +1,315 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace HospitalDatabaseImplement.Migrations +{ + /// + public partial class InitCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Doctors", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FullName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + Post = table.Column(type: "int", nullable: false), + Email = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + Password = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Doctors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Medicines", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + Description = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Medicines", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Procedures", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + Description = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Procedures", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Patients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FullName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + BirthDate = table.Column(type: "datetime2", nullable: false), + Phone = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: false), + DoctorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Patients", x => x.Id); + table.ForeignKey( + name: "FK_Patients_Doctors_DoctorId", + column: x => x.DoctorId, + principalTable: "Doctors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Recipes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + IssueDate = table.Column(type: "datetime2", nullable: false), + DoctorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Recipes", x => x.Id); + table.ForeignKey( + name: "FK_Recipes_Doctors_DoctorId", + column: x => x.DoctorId, + principalTable: "Doctors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProcedureMedicines", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ProcedureId = table.Column(type: "int", nullable: false), + MedicineId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProcedureMedicines", x => x.Id); + table.ForeignKey( + name: "FK_ProcedureMedicines_Medicines_MedicineId", + column: x => x.MedicineId, + principalTable: "Medicines", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProcedureMedicines_Procedures_ProcedureId", + column: x => x.ProcedureId, + principalTable: "Procedures", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "PatientProcedures", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PatientId = table.Column(type: "int", nullable: false), + ProcedureId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PatientProcedures", x => x.Id); + table.ForeignKey( + name: "FK_PatientProcedures_Patients_PatientId", + column: x => x.PatientId, + principalTable: "Patients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PatientProcedures_Procedures_ProcedureId", + column: x => x.ProcedureId, + principalTable: "Procedures", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Diseases", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(30)", maxLength: 30, nullable: false), + Symptoms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + RecipeId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Diseases", x => x.Id); + table.ForeignKey( + name: "FK_Diseases_Recipes_RecipeId", + column: x => x.RecipeId, + principalTable: "Recipes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "PatientRecipes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PatientId = table.Column(type: "int", nullable: false), + RecipeId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PatientRecipes", x => x.Id); + table.ForeignKey( + name: "FK_PatientRecipes_Patients_PatientId", + column: x => x.PatientId, + principalTable: "Patients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_PatientRecipes_Recipes_RecipeId", + column: x => x.RecipeId, + principalTable: "Recipes", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "RecipeMedicines", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RecipeId = table.Column(type: "int", nullable: false), + MedicineId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RecipeMedicines", x => x.Id); + table.ForeignKey( + name: "FK_RecipeMedicines_Medicines_MedicineId", + column: x => x.MedicineId, + principalTable: "Medicines", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RecipeMedicines_Recipes_RecipeId", + column: x => x.RecipeId, + principalTable: "Recipes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Diseases_RecipeId", + table: "Diseases", + column: "RecipeId"); + + migrationBuilder.CreateIndex( + name: "IX_PatientProcedures_PatientId", + table: "PatientProcedures", + column: "PatientId"); + + migrationBuilder.CreateIndex( + name: "IX_PatientProcedures_ProcedureId", + table: "PatientProcedures", + column: "ProcedureId"); + + migrationBuilder.CreateIndex( + name: "IX_PatientRecipes_PatientId", + table: "PatientRecipes", + column: "PatientId"); + + migrationBuilder.CreateIndex( + name: "IX_PatientRecipes_RecipeId", + table: "PatientRecipes", + column: "RecipeId"); + + migrationBuilder.CreateIndex( + name: "IX_Patients_DoctorId", + table: "Patients", + column: "DoctorId"); + + migrationBuilder.CreateIndex( + name: "IX_ProcedureMedicines_MedicineId", + table: "ProcedureMedicines", + column: "MedicineId"); + + migrationBuilder.CreateIndex( + name: "IX_ProcedureMedicines_ProcedureId", + table: "ProcedureMedicines", + column: "ProcedureId"); + + migrationBuilder.CreateIndex( + name: "IX_RecipeMedicines_MedicineId", + table: "RecipeMedicines", + column: "MedicineId"); + + migrationBuilder.CreateIndex( + name: "IX_RecipeMedicines_RecipeId", + table: "RecipeMedicines", + column: "RecipeId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_DoctorId", + table: "Recipes", + column: "DoctorId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Diseases"); + + migrationBuilder.DropTable( + name: "PatientProcedures"); + + migrationBuilder.DropTable( + name: "PatientRecipes"); + + migrationBuilder.DropTable( + name: "ProcedureMedicines"); + + migrationBuilder.DropTable( + name: "RecipeMedicines"); + + migrationBuilder.DropTable( + name: "Patients"); + + migrationBuilder.DropTable( + name: "Procedures"); + + migrationBuilder.DropTable( + name: "Medicines"); + + migrationBuilder.DropTable( + name: "Recipes"); + + migrationBuilder.DropTable( + name: "Doctors"); + } + } +} diff --git a/Hospital/HospitalDatabaseImplement/Migrations/HospitalDatabaseModelSnapshot.cs b/Hospital/HospitalDatabaseImplement/Migrations/HospitalDatabaseModelSnapshot.cs new file mode 100644 index 0000000..1492245 --- /dev/null +++ b/Hospital/HospitalDatabaseImplement/Migrations/HospitalDatabaseModelSnapshot.cs @@ -0,0 +1,399 @@ +// +using System; +using HospitalDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace HospitalDatabaseImplement.Migrations +{ + [DbContext(typeof(HospitalDatabase))] + partial class HospitalDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.13") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.Property("Symptoms") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("RecipeId"); + + b.ToTable("Diseases"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Post") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Doctors"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.ToTable("Medicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("BirthDate") + .HasColumnType("datetime2"); + + b.Property("DoctorId") + .HasColumnType("int"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Phone") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b.HasKey("Id"); + + b.HasIndex("DoctorId"); + + b.ToTable("Patients"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PatientId") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PatientId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("PatientProcedures"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PatientId") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("PatientId"); + + b.HasIndex("RecipeId"); + + b.ToTable("PatientRecipes"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.HasKey("Id"); + + b.ToTable("Procedures"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MedicineId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("ProcedureMedicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DoctorId") + .HasColumnType("int"); + + b.Property("IssueDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("DoctorId"); + + b.ToTable("Recipes"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("MedicineId") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MedicineId"); + + b.HasIndex("RecipeId"); + + b.ToTable("RecipeMedicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Disease", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Recipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor") + .WithMany() + .HasForeignKey("DoctorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Doctor"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient") + .WithMany("Procedures") + .HasForeignKey("PatientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Patient"); + + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Patient", "Patient") + .WithMany("Recipes") + .HasForeignKey("PatientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Recipe", "Recipe") + .WithMany() + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Patient"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") + .WithMany() + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Procedure", "Procedure") + .WithMany("Medicines") + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medicine"); + + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Doctor", "Doctor") + .WithMany() + .HasForeignKey("DoctorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Doctor"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b => + { + b.HasOne("HospitalDatabaseImplement.Models.Medicine", "Medicine") + .WithMany() + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("HospitalDatabaseImplement.Models.Recipe", "Recipe") + .WithMany("Medicines") + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medicine"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b => + { + b.Navigation("Procedures"); + + b.Navigation("Recipes"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b => + { + b.Navigation("Medicines"); + }); + + modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b => + { + b.Navigation("Medicines"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hospital/HospitalRestApi/Controllers/WeatherForecastController.cs b/Hospital/HospitalRestApi/Controllers/WeatherForecastController.cs new file mode 100644 index 0000000..2369fee --- /dev/null +++ b/Hospital/HospitalRestApi/Controllers/WeatherForecastController.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Mvc; + +namespace HospitalRestApi.Controllers +{ + [ApiController] + [Route("[controller]")] + public class WeatherForecastController : ControllerBase + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + private readonly ILogger _logger; + + public WeatherForecastController(ILogger logger) + { + _logger = logger; + } + + [HttpGet(Name = "GetWeatherForecast")] + public IEnumerable Get() + { + return Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = DateTime.Now.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + Summary = Summaries[Random.Shared.Next(Summaries.Length)] + }) + .ToArray(); + } + } +} diff --git a/Hospital/HospitalRestApi/HospitalRestApi.csproj b/Hospital/HospitalRestApi/HospitalRestApi.csproj new file mode 100644 index 0000000..da80aa6 --- /dev/null +++ b/Hospital/HospitalRestApi/HospitalRestApi.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + diff --git a/Hospital/HospitalRestApi/Program.cs b/Hospital/HospitalRestApi/Program.cs new file mode 100644 index 0000000..e5ad895 --- /dev/null +++ b/Hospital/HospitalRestApi/Program.cs @@ -0,0 +1,61 @@ +using HospitalBusinessLogics.BusinessLogics; +using HospitalBusinessLogics.OfficePackage.Implements; +using HospitalBusinessLogics.OfficePackage; +using HospitalContracts.BusinessLogicsContracts; +using HospitalContracts.StoragesContracts; +using HospitalDatabaseImplement.Implements; +using Microsoft.OpenApi.Models; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +// Logger service +builder.Logging.SetMinimumLevel(LogLevel.Trace); +builder.Logging.AddLog4Net("log4net.config"); + +// Storage services +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +// BusinessLogic services +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +// BusinessLogic Reports services +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo { Title = "HospitalRestApi", Version = "v1" }); +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HospitalRestApi v1")); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/Hospital/HospitalRestApi/Properties/launchSettings.json b/Hospital/HospitalRestApi/Properties/launchSettings.json new file mode 100644 index 0000000..322dfa3 --- /dev/null +++ b/Hospital/HospitalRestApi/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:20442", + "sslPort": 44332 + } + }, + "profiles": { + "HospitalRestApi": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7267;http://localhost:5235", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Hospital/HospitalRestApi/WeatherForecast.cs b/Hospital/HospitalRestApi/WeatherForecast.cs new file mode 100644 index 0000000..393c7f4 --- /dev/null +++ b/Hospital/HospitalRestApi/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace HospitalRestApi +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/Hospital/HospitalRestApi/appsettings.Development.json b/Hospital/HospitalRestApi/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/Hospital/HospitalRestApi/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Hospital/HospitalRestApi/appsettings.json b/Hospital/HospitalRestApi/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Hospital/HospitalRestApi/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Hospital/HospitalRestApi/log4net.config b/Hospital/HospitalRestApi/log4net.config new file mode 100644 index 0000000..3df86b0 --- /dev/null +++ b/Hospital/HospitalRestApi/log4net.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Hospital/HospitalWebApp/Program.cs b/Hospital/HospitalWebApp/Program.cs index f34499a..3ea86a8 100644 --- a/Hospital/HospitalWebApp/Program.cs +++ b/Hospital/HospitalWebApp/Program.cs @@ -1,38 +1,10 @@ -using HospitalContracts.BusinessLogicsContracts; -using HospitalBusinessLogics.BusinessLogics; -using HospitalContracts.StoragesContracts; -using HospitalDatabaseImplement.Implements; using HospitalWebApp; -using HospitalBusinessLogics.OfficePackage; -using HospitalBusinessLogics.OfficePackage.Implements; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); -// Storage services -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); - -// BusinessLogic services -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); - -// BusinessLogic Reports services -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); -builder.Services.AddTransient(); - var app = builder.Build(); APIClient.Connect(builder.Configuration); diff --git a/Hospital/HospitalWebApp/appsettings.json b/Hospital/HospitalWebApp/appsettings.json index 60dbdac..d0eae23 100644 --- a/Hospital/HospitalWebApp/appsettings.json +++ b/Hospital/HospitalWebApp/appsettings.json @@ -7,5 +7,5 @@ }, "AllowedHosts": "*", - "IPAddress": "http://localhost:" + "IPAddress": "http://localhost:5235" }