DatabaseImplement / Add migration

RestApi
This commit is contained in:
parent 7be670bdd3
commit 023b71c547
15 changed files with 1327 additions and 34 deletions

View File

@ -11,7 +11,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalDatabaseImplement",
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalBusinessLogics", "HospitalBusinessLogics\HospitalBusinessLogics.csproj", "{1A20292D-5690-4C8A-859E-9CC72F0AACB5}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HospitalBusinessLogics", "HospitalBusinessLogics\HospitalBusinessLogics.csproj", "{1A20292D-5690-4C8A-859E-9CC72F0AACB5}"
EndProject 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 EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution 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}.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.ActiveCfg = Release|Any CPU
{024326F5-A7A5-41B5-9BEB-C1B10A533F23}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,5 +1,6 @@
using HospitalBusinessLogics.OfficePackage.HelperEnums; using HospitalBusinessLogics.OfficePackage.HelperEnums;
using HospitalBusinessLogics.OfficePackage.HelperModels; using HospitalBusinessLogics.OfficePackage.HelperModels;
using HospitalContracts.ViewModels;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -61,13 +62,17 @@ namespace HospitalBusinessLogics.OfficePackage
ParagraphAlignment = PdfParagraphAlignmentType.Left ParagraphAlignment = PdfParagraphAlignmentType.Left
}); });
// Конвертируем из HashSet в List, чтобы можно было обращаться по индексу
List<MedicineViewModel> medicines = new List<MedicineViewModel>(view.Medicines);
List<DiseaseViewModel> diseases = new List<DiseaseViewModel>(view.Diseases);
// Записываем названия лекарств во 2 колонку // Записываем названия лекарств во 2 колонку
// и названия лекарств в 3 колонку // и названия лекарств в 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++) for (int i = 0; i < maxLength; i++)
{ {
string medicine = (i < view.Medicines.Count) ? view.Medicines[i].Name : ""; string medicine = (i < medicines.Count) ? medicines[i].Name : "";
string disease = (i < view.Diseases.Count) ? view.Diseases[i].Name : ""; string disease = (i < diseases.Count) ? diseases[i].Name : "";
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { "", medicine, disease }, Texts = new List<string> { "", medicine, disease },

View File

@ -0,0 +1,402 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.Property<string>("Symptoms")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.HasKey("Id");
b.HasIndex("RecipeId");
b.ToTable("Diseases");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<int>("Post")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Doctors");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Id");
b.ToTable("Medicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("BirthDate")
.HasColumnType("datetime2");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Phone")
.IsRequired()
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Patients");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("ProcedureId");
b.ToTable("PatientProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("RecipeId");
b.ToTable("PatientRecipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Id");
b.ToTable("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("ProcedureId");
b.ToTable("ProcedureMedicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<DateTime>("IssueDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("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
}
}
}

View File

@ -0,0 +1,315 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace HospitalDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Doctors",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
Post = table.Column<int>(type: "int", nullable: false),
Email = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Password = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Description = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Description = table.Column<string>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FullName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
BirthDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Phone = table.Column<string>(type: "nvarchar(16)", maxLength: 16, nullable: false),
DoctorId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
IssueDate = table.Column<DateTime>(type: "datetime2", nullable: false),
DoctorId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProcedureId = table.Column<int>(type: "int", nullable: false),
MedicineId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PatientId = table.Column<int>(type: "int", nullable: false),
ProcedureId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(30)", maxLength: 30, nullable: false),
Symptoms = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
RecipeId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PatientId = table.Column<int>(type: "int", nullable: false),
RecipeId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RecipeId = table.Column<int>(type: "int", nullable: false),
MedicineId = table.Column<int>(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");
}
/// <inheritdoc />
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");
}
}
}

View File

@ -0,0 +1,399 @@
// <auto-generated />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.Property<string>("Symptoms")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.HasKey("Id");
b.HasIndex("RecipeId");
b.ToTable("Diseases");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Doctor", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<int>("Post")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Doctors");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Medicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Id");
b.ToTable("Medicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Patient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("BirthDate")
.HasColumnType("datetime2");
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Phone")
.IsRequired()
.HasMaxLength(16)
.HasColumnType("nvarchar(16)");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Patients");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("ProcedureId");
b.ToTable("PatientProcedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.PatientRecipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PatientId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PatientId");
b.HasIndex("RecipeId");
b.ToTable("PatientRecipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Procedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.HasKey("Id");
b.ToTable("Procedures");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.ProcedureMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("ProcedureId");
b.ToTable("ProcedureMedicines");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.Recipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DoctorId")
.HasColumnType("int");
b.Property<DateTime>("IssueDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("DoctorId");
b.ToTable("Recipes");
});
modelBuilder.Entity("HospitalDatabaseImplement.Models.RecipeMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("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
}
}
}

View File

@ -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<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> 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();
}
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HospitalBusinessLogics\HospitalBusinessLogics.csproj" />
<ProjectReference Include="..\HospitalDatabaseImplement\HospitalDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -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<IDoctorStorage, DoctorStorage>();
builder.Services.AddTransient<IPatientStorage, PatientStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IDiseaseStorage, DiseaseStorage>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicineStorage, MedicineStorage>();
// BusinessLogic services
builder.Services.AddTransient<IDoctorLogic, DoctorLogic>();
builder.Services.AddTransient<IPatientLogic, PatientLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IDiseaseLogic, DiseaseLogic>();
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
// BusinessLogic Reports services
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
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();

View File

@ -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"
}
}
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="D:\ULSTU\Семестр 4\РПП Coursework\Hospital/log-${shortdate}.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception" />
</layout>
</appender>
<root>
<level value="TRACE" />
<appender-ref ref="RollingFile" />
</root>
</log4net>

View File

@ -1,38 +1,10 @@
using HospitalContracts.BusinessLogicsContracts;
using HospitalBusinessLogics.BusinessLogics;
using HospitalContracts.StoragesContracts;
using HospitalDatabaseImplement.Implements;
using HospitalWebApp; using HospitalWebApp;
using HospitalBusinessLogics.OfficePackage;
using HospitalBusinessLogics.OfficePackage.Implements;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
// Storage services
builder.Services.AddTransient<IDoctorStorage, DoctorStorage>();
builder.Services.AddTransient<IPatientStorage, PatientStorage>();
builder.Services.AddTransient<IRecipeStorage, RecipeStorage>();
builder.Services.AddTransient<IDiseaseStorage, DiseaseStorage>();
builder.Services.AddTransient<IProcedureStorage, ProcedureStorage>();
builder.Services.AddTransient<IMedicineStorage, MedicineStorage>();
// BusinessLogic services
builder.Services.AddTransient<IDoctorLogic, DoctorLogic>();
builder.Services.AddTransient<IPatientLogic, PatientLogic>();
builder.Services.AddTransient<IRecipeLogic, RecipeLogic>();
builder.Services.AddTransient<IDiseaseLogic, DiseaseLogic>();
builder.Services.AddTransient<IProcedureLogic, ProcedureLogic>();
builder.Services.AddTransient<IMedicineLogic, MedicineLogic>();
// BusinessLogic Reports services
builder.Services.AddTransient<IReportLogic, ReportLogic>();
builder.Services.AddTransient<AbstractSaveToWord, SaveToWord>();
builder.Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
builder.Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
var app = builder.Build(); var app = builder.Build();
APIClient.Connect(builder.Configuration); APIClient.Connect(builder.Configuration);

View File

@ -7,5 +7,5 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"IPAddress": "http://localhost:" "IPAddress": "http://localhost:5235"
} }