This commit is contained in:
Никита Потапов 2024-05-30 03:05:50 +04:00
commit 9a8a398e5f
7 changed files with 622 additions and 16 deletions

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.BindingModels
{
public int Id { get; set; }
public int? SymptomId { get; set; }
public int ProcedureId { get; set; }
public int? ProcedureId { get; set; }
public string Name { get; set; } = string.Empty;
public string? Comment { get; set; } = string.Empty;
}

View File

@ -6,7 +6,7 @@ namespace PolyclinicContracts.ViewModels
public class MedicamentViewModel : IMedicamentModel
{
public int Id { get; set; }
public int ProcedureId { get; set; }
public int? ProcedureId { get; set; }
public int? SymptomId { get; set; }
[DisplayName("Название медикамента")]

View File

@ -4,7 +4,7 @@
{
string Name { get; }
string? Comment { get; }
int ProcedureId { get; }
int? ProcedureId { get; }
int? SymptomId { get; }
}
}

View File

@ -0,0 +1,448 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SecuritySystemDatabaseImplement;
#nullable disable
namespace PolyclinicDatabaseImplement.Migrations
{
[DbContext(typeof(PolyclinicDatabase))]
[Migration("20240529230147_For-Medicaments")]
partial class ForMedicaments
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.16")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Course", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<int>("DaysCount")
.HasColumnType("int");
b.Property<int>("PillsPerDay")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Courses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.CourseDiagnose", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CourseId")
.HasColumnType("int");
b.Property<int>("DiagnoseId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CourseId");
b.HasIndex("DiagnoseId");
b.ToTable("CourseDiagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Diagnose", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartDiagnose")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateStopDiagnose")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Diagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Medicament", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ProcedureId")
.HasColumnType("int");
b.Property<int?>("SymptomId")
.IsRequired()
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProcedureId");
b.HasIndex("SymptomId");
b.ToTable("Medicaments");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Procedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartProcedure")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateStopProcedure")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Procedures");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CourseId")
.HasColumnType("int");
b.Property<int>("ProceduresCount")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CourseId");
b.ToTable("Recipes");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.RecipeProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.Property<int>("RecipeId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProcedureId");
b.HasIndex("RecipeId");
b.ToTable("RecipeProcedures");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Symptom", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Symptomes");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomDiagnose", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DiagnoseId")
.HasColumnType("int");
b.Property<int>("SymptomId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DiagnoseId");
b.HasIndex("SymptomId");
b.ToTable("SymptomDiagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomRecipe", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("RecipeId")
.HasColumnType("int");
b.Property<int>("SymptomId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("RecipeId");
b.HasIndex("SymptomId");
b.ToTable("SymptomRecipes");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("FIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Role")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.CourseDiagnose", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course")
.WithMany("Diagnoses")
.HasForeignKey("CourseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Diagnose", "Diagnose")
.WithMany()
.HasForeignKey("DiagnoseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Course");
b.Navigation("Diagnose");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Diagnose", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Medicament", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure")
.WithMany()
.HasForeignKey("ProcedureId");
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany()
.HasForeignKey("SymptomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Procedure");
b.Navigation("Symptom");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Procedure", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Course", "Course")
.WithMany()
.HasForeignKey("CourseId");
b.Navigation("Course");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.RecipeProcedure", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure")
.WithMany()
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Recipe", "Recipe")
.WithMany("Procedures")
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Procedure");
b.Navigation("Recipe");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomDiagnose", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Diagnose", "Diagnose")
.WithMany()
.HasForeignKey("DiagnoseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany("Diagnoses")
.HasForeignKey("SymptomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Diagnose");
b.Navigation("Symptom");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.SymptomRecipe", b =>
{
b.HasOne("PolyclinicDatabaseImplement.Models.Recipe", "Recipe")
.WithMany()
.HasForeignKey("RecipeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany()
.HasForeignKey("SymptomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Recipe");
b.Navigation("Symptom");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Course", b =>
{
b.Navigation("Diagnoses");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Recipe", b =>
{
b.Navigation("Procedures");
});
modelBuilder.Entity("PolyclinicDatabaseImplement.Models.Symptom", b =>
{
b.Navigation("Diagnoses");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,167 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PolyclinicDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class ForMedicaments : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Symptomes",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Recipes",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Procedures",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<int>(
name: "ProcedureId",
table: "Medicaments",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Medicaments",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Diagnoses",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Courses",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)");
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments",
column: "ProcedureId",
principalTable: "Procedures",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments");
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Symptomes",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Recipes",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Procedures",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ProcedureId",
table: "Medicaments",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Medicaments",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Diagnoses",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Comment",
table: "Courses",
type: "nvarchar(max)",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Medicaments_Procedures_ProcedureId",
table: "Medicaments",
column: "ProcedureId",
principalTable: "Procedures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -31,7 +31,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("DaysCount")
@ -77,7 +76,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartDiagnose")
@ -109,14 +107,13 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ProcedureId")
b.Property<int?>("ProcedureId")
.HasColumnType("int");
b.Property<int?>("SymptomId")
@ -141,7 +138,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateStartProcedure")
@ -173,7 +169,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("CourseId")
@ -221,7 +216,6 @@ namespace PolyclinicDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Comment")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
@ -341,9 +335,7 @@ namespace PolyclinicDatabaseImplement.Migrations
{
b.HasOne("PolyclinicDatabaseImplement.Models.Procedure", "Procedure")
.WithMany()
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("ProcedureId");
b.HasOne("PolyclinicDatabaseImplement.Models.Symptom", "Symptom")
.WithMany()

View File

@ -15,8 +15,7 @@ namespace PolyclinicDatabaseImplement.Models
public string? Comment { get; set; } = string.Empty;
[Required]
public int ProcedureId { get; set; }
public int? ProcedureId { get; set; }
[Required]
public int? SymptomId { get; set; }
@ -49,7 +48,7 @@ namespace PolyclinicDatabaseImplement.Models
Id = Id,
Name = Name,
Comment = Comment,
ProcedureId = ProcedureId,
ProcedureId = Procedure?.Id ?? null,
SymptomId = Symptom?.Id ?? null,
SymptomName = Symptom?.Name ?? string.Empty,
ProcedureName = Procedure?.Name ?? string.Empty,