Проверка бд
This commit is contained in:
parent
1edcb20fce
commit
f8636eeb4d
@ -13,6 +13,7 @@ namespace HospitalContracts.BindingModels
|
||||
public string Dose { get; set; } = string.Empty;
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public string ModeOfApplication { get; set; } = string.Empty;
|
||||
public int ClientId { get; set; }
|
||||
public int MedicinesId { get; set; }
|
||||
public Dictionary<int, ISymptomsModel> RecipeSymptoms
|
||||
{
|
||||
|
@ -9,5 +9,6 @@ namespace HospitalContracts.SearchModels
|
||||
public class RecipesSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,13 @@ namespace HospitalContracts.ViewModels
|
||||
public class RecipesViewModel: IRecipesModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Доза")]
|
||||
public string Dose { get; set; } = string.Empty;
|
||||
[DisplayName("Дата выписки")]
|
||||
public DateTime Date { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Способ приготовления")]
|
||||
public string ModeOfApplication { get; set; } = string.Empty;
|
||||
[DisplayName("Лекарство")]
|
||||
|
@ -14,7 +14,7 @@ namespace HospitalDataBaseImplements
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-0BJHUJC\SQLEXPRESS;Initial Catalog=GiftShopDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-0BJHUJC\SQLEXPRESS;Initial Catalog=HospitalDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using HospitalContracts.SearchModels;
|
||||
using HospitalContracts.StoragesContracts;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDataBaseImplements.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -33,7 +34,7 @@ namespace HospitalDataBaseImplements.Implements
|
||||
return null;
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Recipes.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
return context.Recipes.Include(x => x.Client).FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<RecipesViewModel> GetFilteredList(RecipesSearchModel model)
|
||||
@ -43,13 +44,13 @@ namespace HospitalDataBaseImplements.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Recipes.Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
return context.Recipes.Include(x => x.Client).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<RecipesViewModel> GetFullList()
|
||||
{
|
||||
using var context = new HospitalDatabase();
|
||||
return context.Recipes.Select(x => x.GetViewModel).ToList();
|
||||
return context.Recipes.Include(x => x.Client).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public RecipesViewModel? Insert(RecipesBindingModel model)
|
||||
|
428
HospitalDataBaseImplements/Migrations/20230406204404_InitialCreate.Designer.cs
generated
Normal file
428
HospitalDataBaseImplements/Migrations/20230406204404_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,428 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HospitalDataBaseImplements;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HospitalDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(HospitalDatabase))]
|
||||
[Migration("20230406204404_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Illness", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Form")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("IllnessName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Illnesses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessKurse", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("IllnessId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("KurseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IllnessId");
|
||||
|
||||
b.HasIndex("KurseId");
|
||||
|
||||
b.ToTable("IllnessKurse");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessSymptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("IllnessId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IllnessId");
|
||||
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("IllnessSymptomses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Kurses", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountInDay")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Duration")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MedicinesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("MedicinesName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicinesId");
|
||||
|
||||
b.ToTable("Kurse");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Medicines", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Group")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MedicinesName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ProceduresName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Dose")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MedicinesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ModeOfApplication")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MedicinesId");
|
||||
|
||||
b.ToTable("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesProcedures", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("RecipesId");
|
||||
|
||||
b.ToTable("RecipesProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("RecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RecipesId");
|
||||
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("RecipesSymptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Symptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SymptomName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Symptomses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessKurse", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Illness", "Illness")
|
||||
.WithMany("Kurses")
|
||||
.HasForeignKey("IllnessId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Kurses", "Kurse")
|
||||
.WithMany("IllnessKurses")
|
||||
.HasForeignKey("KurseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Illness");
|
||||
|
||||
b.Navigation("Kurse");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessSymptoms", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Illness", "Illness")
|
||||
.WithMany("Symptomses")
|
||||
.HasForeignKey("IllnessId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany("IllnessSymptomses")
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Illness");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Kurses", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicines")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicinesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Client", "Client")
|
||||
.WithMany("Recipes")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicines")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicinesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesProcedures", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Procedures", "Procedure")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Recipes", "Recipe")
|
||||
.WithMany("Procedures")
|
||||
.HasForeignKey("RecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Recipe");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Recipes", "Recipe")
|
||||
.WithMany("Symptoms")
|
||||
.HasForeignKey("RecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany()
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Recipe");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Illness", b =>
|
||||
{
|
||||
b.Navigation("Kurses");
|
||||
|
||||
b.Navigation("Symptomses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Kurses", b =>
|
||||
{
|
||||
b.Navigation("IllnessKurses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.Navigation("Procedures");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Symptoms", b =>
|
||||
{
|
||||
b.Navigation("IllnessSymptomses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HospitalDataBaseImplements.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Illnesses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
IllnessName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Form = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Illnesses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Medicines",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MedicinesName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Group = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
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"),
|
||||
ProceduresName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Type = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Procedures", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Symptomses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
SymptomName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Symptomses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Kurse",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
MedicinesId = table.Column<int>(type: "int", nullable: false),
|
||||
MedicinesName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Duration = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
CountInDay = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Kurse", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Kurse_Medicines_MedicinesId",
|
||||
column: x => x.MedicinesId,
|
||||
principalTable: "Medicines",
|
||||
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"),
|
||||
Dose = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
MedicinesId = table.Column<int>(type: "int", nullable: false),
|
||||
ModeOfApplication = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Recipes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Recipes_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Recipes_Medicines_MedicinesId",
|
||||
column: x => x.MedicinesId,
|
||||
principalTable: "Medicines",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "IllnessSymptomses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
IllnessId = table.Column<int>(type: "int", nullable: false),
|
||||
SymptomsId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_IllnessSymptomses", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_IllnessSymptomses_Illnesses_IllnessId",
|
||||
column: x => x.IllnessId,
|
||||
principalTable: "Illnesses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_IllnessSymptomses_Symptomses_SymptomsId",
|
||||
column: x => x.SymptomsId,
|
||||
principalTable: "Symptomses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "IllnessKurse",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
IllnessId = table.Column<int>(type: "int", nullable: false),
|
||||
KurseId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_IllnessKurse", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_IllnessKurse_Illnesses_IllnessId",
|
||||
column: x => x.IllnessId,
|
||||
principalTable: "Illnesses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_IllnessKurse_Kurse_KurseId",
|
||||
column: x => x.KurseId,
|
||||
principalTable: "Kurse",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RecipesProcedures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RecipesId = table.Column<int>(type: "int", nullable: false),
|
||||
ProcedureId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RecipesProcedures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecipesProcedures_Procedures_ProcedureId",
|
||||
column: x => x.ProcedureId,
|
||||
principalTable: "Procedures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecipesProcedures_Recipes_RecipesId",
|
||||
column: x => x.RecipesId,
|
||||
principalTable: "Recipes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RecipesSymptoms",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
RecipesId = table.Column<int>(type: "int", nullable: false),
|
||||
SymptomsId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RecipesSymptoms", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecipesSymptoms_Recipes_RecipesId",
|
||||
column: x => x.RecipesId,
|
||||
principalTable: "Recipes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RecipesSymptoms_Symptomses_SymptomsId",
|
||||
column: x => x.SymptomsId,
|
||||
principalTable: "Symptomses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_IllnessKurse_IllnessId",
|
||||
table: "IllnessKurse",
|
||||
column: "IllnessId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_IllnessKurse_KurseId",
|
||||
table: "IllnessKurse",
|
||||
column: "KurseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_IllnessSymptomses_IllnessId",
|
||||
table: "IllnessSymptomses",
|
||||
column: "IllnessId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_IllnessSymptomses_SymptomsId",
|
||||
table: "IllnessSymptomses",
|
||||
column: "SymptomsId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Kurse_MedicinesId",
|
||||
table: "Kurse",
|
||||
column: "MedicinesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Recipes_ClientId",
|
||||
table: "Recipes",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Recipes_MedicinesId",
|
||||
table: "Recipes",
|
||||
column: "MedicinesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecipesProcedures_ProcedureId",
|
||||
table: "RecipesProcedures",
|
||||
column: "ProcedureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecipesProcedures_RecipesId",
|
||||
table: "RecipesProcedures",
|
||||
column: "RecipesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecipesSymptoms_RecipesId",
|
||||
table: "RecipesSymptoms",
|
||||
column: "RecipesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RecipesSymptoms_SymptomsId",
|
||||
table: "RecipesSymptoms",
|
||||
column: "SymptomsId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "IllnessKurse");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "IllnessSymptomses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RecipesProcedures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RecipesSymptoms");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Kurse");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Illnesses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Procedures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Recipes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Symptomses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Medicines");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,425 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HospitalDataBaseImplements;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HospitalDataBaseImplements.Migrations
|
||||
{
|
||||
[DbContext(typeof(HospitalDatabase))]
|
||||
partial class HospitalDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Illness", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Form")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("IllnessName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Illnesses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessKurse", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("IllnessId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("KurseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IllnessId");
|
||||
|
||||
b.HasIndex("KurseId");
|
||||
|
||||
b.ToTable("IllnessKurse");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessSymptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("IllnessId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IllnessId");
|
||||
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("IllnessSymptomses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Kurses", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("CountInDay")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Duration")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MedicinesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("MedicinesName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("MedicinesId");
|
||||
|
||||
b.ToTable("Kurse");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Medicines", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Group")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("MedicinesName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Procedures", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ProceduresName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Procedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("Date")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("Dose")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MedicinesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ModeOfApplication")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("MedicinesId");
|
||||
|
||||
b.ToTable("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesProcedures", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ProcedureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("RecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ProcedureId");
|
||||
|
||||
b.HasIndex("RecipesId");
|
||||
|
||||
b.ToTable("RecipesProcedures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("RecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SymptomsId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RecipesId");
|
||||
|
||||
b.HasIndex("SymptomsId");
|
||||
|
||||
b.ToTable("RecipesSymptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Symptoms", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("SymptomName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Symptomses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessKurse", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Illness", "Illness")
|
||||
.WithMany("Kurses")
|
||||
.HasForeignKey("IllnessId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Kurses", "Kurse")
|
||||
.WithMany("IllnessKurses")
|
||||
.HasForeignKey("KurseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Illness");
|
||||
|
||||
b.Navigation("Kurse");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.IllnessSymptoms", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Illness", "Illness")
|
||||
.WithMany("Symptomses")
|
||||
.HasForeignKey("IllnessId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany("IllnessSymptomses")
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Illness");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Kurses", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicines")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicinesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Client", "Client")
|
||||
.WithMany("Recipes")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Medicines", "Medicines")
|
||||
.WithMany()
|
||||
.HasForeignKey("MedicinesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Medicines");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesProcedures", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Procedures", "Procedure")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProcedureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Recipes", "Recipe")
|
||||
.WithMany("Procedures")
|
||||
.HasForeignKey("RecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Procedure");
|
||||
|
||||
b.Navigation("Recipe");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.RecipesSymptoms", b =>
|
||||
{
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Recipes", "Recipe")
|
||||
.WithMany("Symptoms")
|
||||
.HasForeignKey("RecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HospitalDataBaseImplements.Models.Symptoms", "Symptoms")
|
||||
.WithMany()
|
||||
.HasForeignKey("SymptomsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Recipe");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Illness", b =>
|
||||
{
|
||||
b.Navigation("Kurses");
|
||||
|
||||
b.Navigation("Symptomses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Kurses", b =>
|
||||
{
|
||||
b.Navigation("IllnessKurses");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Recipes", b =>
|
||||
{
|
||||
b.Navigation("Procedures");
|
||||
|
||||
b.Navigation("Symptoms");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HospitalDataBaseImplements.Models.Symptoms", b =>
|
||||
{
|
||||
b.Navigation("IllnessSymptomses");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -22,9 +22,7 @@ namespace HospitalDataBaseImplements.Models
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[ForeignKey("ClientId")]
|
||||
//public virtual List<Medicines> Medicines { get; set; } = new();
|
||||
//public virtual List<Procedures> Procedures { get; set; } = new();
|
||||
//public virtual List<Recipes> Recipes { get; set; } = new();
|
||||
public virtual List<Recipes> Recipes { get; set; } = new();
|
||||
|
||||
public static Client? Create(ClientBindingModel model)
|
||||
{
|
||||
|
@ -14,13 +14,16 @@ namespace HospitalDataBaseImplements.Models
|
||||
public class Kurses : IKurseModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[ForeignKey("MedicinesId")]
|
||||
public int MedicinesId { get; private set; }
|
||||
public virtual Medicines Medicines { get; set; } = new();
|
||||
public string MedicinesName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Duration { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int CountInDay { get; private set; }
|
||||
[ForeignKey("DrugCourseId")]
|
||||
[ForeignKey("KurseId")]
|
||||
|
||||
public virtual List<IllnessKurse> IllnessKurses { get; set; } = new();
|
||||
public static Kurses? Create(KurseBindingModel model)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ using HospitalDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -1,10 +1,13 @@
|
||||
using HospitalContracts.BindingModels;
|
||||
using HospitalContracts.ViewModels;
|
||||
using HospitalDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore.Query.Internal;
|
||||
using Microsoft.Identity.Client;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -18,9 +21,13 @@ namespace HospitalDataBaseImplements.Models
|
||||
public string Dose { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime Date { get; private set; } = DateTime.Now;
|
||||
[Required]
|
||||
public int ClientId { get; set; }
|
||||
public virtual Medicines Medicines { get; set; } = new();
|
||||
public int MedicinesId { get; private set; }
|
||||
[Required]
|
||||
public string ModeOfApplication { get; private set; } = string.Empty;
|
||||
public Client Client { get; set; }
|
||||
private Dictionary<int, IProceduresModel>? _recipeProcedures = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, IProceduresModel> RecipeProcedures
|
||||
@ -30,12 +37,12 @@ namespace HospitalDataBaseImplements.Models
|
||||
if (_recipeProcedures == null)
|
||||
{
|
||||
_recipeProcedures = Procedures.ToDictionary(recPC => recPC.ProcedureId, recPC =>
|
||||
recPC.Procedures as IProceduresModel);
|
||||
recPC.Procedure as IProceduresModel);
|
||||
}
|
||||
return _recipeProcedures;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ProceduresId")]
|
||||
[ForeignKey("RecipesId")]
|
||||
public virtual List<RecipesProcedures> Procedures { get; set; } = new();
|
||||
|
||||
private Dictionary<int, ISymptomsModel>? _recipeSymptoms = null;
|
||||
@ -51,7 +58,6 @@ namespace HospitalDataBaseImplements.Models
|
||||
return _recipeSymptoms;
|
||||
}
|
||||
}
|
||||
[ForeignKey("SymptomsId")]
|
||||
public virtual List<RecipesSymptoms> Symptoms { get; set; } = new();
|
||||
|
||||
public static Recipes Create(HospitalDatabase context, RecipesBindingModel model)
|
||||
@ -61,9 +67,10 @@ namespace HospitalDataBaseImplements.Models
|
||||
Id = model.Id,
|
||||
Date = model.Date,
|
||||
MedicinesId = model.MedicinesId,
|
||||
ClientId = model.ClientId,
|
||||
Procedures = model.RecipeProcedures.Select(x => new RecipesProcedures
|
||||
{
|
||||
Procedures = context.Procedures.First(y => y.Id == x.Key),
|
||||
Procedure = context.Procedures.First(y => y.Id == x.Key),
|
||||
}).ToList(),
|
||||
Symptoms = model.RecipeSymptoms.Select(x => new RecipesSymptoms
|
||||
{
|
||||
@ -76,16 +83,24 @@ namespace HospitalDataBaseImplements.Models
|
||||
Date = model.Date;
|
||||
MedicinesId = model.MedicinesId;
|
||||
}
|
||||
public RecipesViewModel GetViewModel => new()
|
||||
public RecipesViewModel GetViewModel
|
||||
{
|
||||
Id = Id,
|
||||
Date = Date,
|
||||
RecipeProcedures = RecipeProcedures,
|
||||
RecipeSymptoms = RecipeSymptoms
|
||||
};
|
||||
get {
|
||||
using var context = new HospitalDatabase();
|
||||
return new RecipesViewModel
|
||||
{
|
||||
Id = Id,
|
||||
Date = Date,
|
||||
ClientId = ClientId,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
|
||||
RecipeProcedures = RecipeProcedures,
|
||||
RecipeSymptoms = RecipeSymptoms
|
||||
};
|
||||
}
|
||||
}
|
||||
public void UpdateProcedures(HospitalDatabase context, RecipesBindingModel model)
|
||||
{
|
||||
var recipeProcedures = context.RecipesProcedures.Where(rec => rec.RecipeId == model.Id).ToList();
|
||||
var recipeProcedures = context.RecipesProcedures.Where(rec => rec.RecipesId == model.Id).ToList();
|
||||
if (recipeProcedures != null && recipeProcedures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.RecipesProcedures.RemoveRange(recipeProcedures.Where(rec
|
||||
@ -97,8 +112,8 @@ namespace HospitalDataBaseImplements.Models
|
||||
{
|
||||
context.RecipesProcedures.Add(new RecipesProcedures
|
||||
{
|
||||
Recipes = recipe,
|
||||
Procedures = context.Procedures.First(x => x.Id == pc.Key)
|
||||
Recipe = recipe,
|
||||
Procedure = context.Procedures.First(x => x.Id == pc.Key)
|
||||
});
|
||||
context.SaveChanges();
|
||||
}
|
||||
@ -106,7 +121,7 @@ namespace HospitalDataBaseImplements.Models
|
||||
}
|
||||
public void UpdateSymptomses(HospitalDatabase context, RecipesBindingModel model)
|
||||
{
|
||||
var recipeSymptomses = context.RecipesSymptoms.Where(rec => rec.RecipeId == model.Id).ToList();
|
||||
var recipeSymptomses = context.RecipesSymptoms.Where(rec => rec.RecipesId == model.Id).ToList();
|
||||
if (recipeSymptomses != null && recipeSymptomses.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.RecipesSymptoms.RemoveRange(recipeSymptomses.Where(rec
|
||||
@ -118,7 +133,7 @@ namespace HospitalDataBaseImplements.Models
|
||||
{
|
||||
context.RecipesSymptoms.Add(new RecipesSymptoms
|
||||
{
|
||||
Recipes = recipe,
|
||||
Recipe = recipe,
|
||||
Symptoms = context.Symptomses.First(x => x.Id == pc.Key)
|
||||
});
|
||||
context.SaveChanges();
|
||||
|
@ -11,10 +11,10 @@ namespace HospitalDataBaseImplements.Models
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int RecipeId { get; set; }
|
||||
public int RecipesId { get; set; }
|
||||
[Required]
|
||||
public int ProcedureId { get; set; }
|
||||
public virtual Recipes Recipes { get; set; } = new();
|
||||
public virtual Procedures Procedures { get; set; } = new();
|
||||
public virtual Recipes Recipe { get; set; } = new();
|
||||
public virtual Procedures Procedure { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ namespace HospitalDataBaseImplements.Models
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int RecipeId { get; set; }
|
||||
public int RecipesId { get; set; }
|
||||
[Required]
|
||||
public int SymptomsId { get; set; }
|
||||
public virtual Recipes Recipes { get; set; } = new();
|
||||
public virtual Recipes Recipe { get; set; } = new();
|
||||
public virtual Symptoms Symptoms { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,7 @@ namespace HospitalDataBaseImplements.Models
|
||||
[Required]
|
||||
public string SymptomName { get; set; } = string.Empty;
|
||||
public string? Description { get; set; } = string.Empty;
|
||||
[ForeignKey("SymptomsId")]
|
||||
public virtual List<IllnessSymptoms> IllnessSymptomses { get; set; } = new();
|
||||
[ForeignKey("SymptomsId")]
|
||||
public virtual List<Recipes> Recipes { get; set; } = new();
|
||||
public static Symptoms? Create(SymptomsBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
|
Loading…
Reference in New Issue
Block a user