ничего не робит

This commit is contained in:
goblinrf 2024-04-26 23:50:58 +04:00
parent 5a3f0e218b
commit 46544140b1
7 changed files with 13 additions and 1442 deletions

View File

@ -8,7 +8,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -19,7 +19,7 @@ namespace VetClinicDataBaseImplement.Implements
if (element != null)
{
var deletedElement = context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
@ -38,7 +38,7 @@ namespace VetClinicDataBaseImplement.Implements
if (model.Id.HasValue)
{
return context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
@ -46,7 +46,7 @@ namespace VetClinicDataBaseImplement.Implements
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password))
{
return context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))
?.GetViewModel;
@ -63,7 +63,7 @@ namespace VetClinicDataBaseImplement.Implements
using var context = new VetClinicDatabase();
return context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.Where(x => x.AdminFIO.Contains(model.AdminFIO))
.Select(x => x.GetViewModel)
@ -75,7 +75,7 @@ namespace VetClinicDataBaseImplement.Implements
using var context = new VetClinicDatabase();
return context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.Select(x => x.GetViewModel)
.ToList();
@ -93,7 +93,7 @@ namespace VetClinicDataBaseImplement.Implements
context.SaveChanges();
return context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.FirstOrDefault(x => x.Id == newAdmin.Id)
?.GetViewModel;
@ -103,7 +103,7 @@ namespace VetClinicDataBaseImplement.Implements
{
using var context = new VetClinicDatabase();
var order = context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
@ -114,7 +114,7 @@ namespace VetClinicDataBaseImplement.Implements
context.SaveChanges();
return context.Admins
//.Include(x => x.Visits)
.Include(x => x.Visits)
.Include(x => x.Animals)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;

View File

@ -1,521 +0,0 @@
// <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 VetClinicDataBaseImplement;
#nullable disable
namespace VetClinicDataBaseImplement.Migrations
{
[DbContext(typeof(VetClinicDatabase))]
[Migration("20240424171203_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AdminFIO")
.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("Admins");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<string>("AnimalName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Family")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("VaccinationId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AdminId");
b.ToTable("Animals");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ServiceId");
b.ToTable("Guidances");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("MedicineName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("Medicines");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AnimalId")
.HasColumnType("int");
b.Property<int>("MedicineId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AnimalId");
b.HasIndex("MedicineId");
b.ToTable("MedicineAnimals");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", 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>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PharmacistFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Pharmacists");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ServiceName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("Services");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("ServiceId");
b.ToTable("ServiceMedicines");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AnimalId")
.HasColumnType("int");
b.Property<double>("CostVaccination")
.HasColumnType("float");
b.Property<DateTime?>("DateStamp")
.IsRequired()
.HasColumnType("datetime2");
b.Property<string>("NameVaccination")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AnimalId");
b.ToTable("Vaccinations");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<DateTime>("DateVisit")
.HasColumnType("datetime2");
b.Property<string>("NameVisit")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AdminId");
b.ToTable("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AnimalId")
.HasColumnType("int");
b.Property<int>("VisitId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AnimalId");
b.HasIndex("VisitId");
b.ToTable("VisitAnimals");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ServiceId")
.HasColumnType("int");
b.Property<int>("VisitId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ServiceId");
b.HasIndex("VisitId");
b.ToTable("ServiceVisits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
.WithMany("Animals")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
.WithMany("Guidances")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Service");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Medicines")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
.WithMany("Medicines")
.HasForeignKey("AnimalId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
.WithMany("Animals")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Animal");
b.Navigation("Medicine");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Services")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
.WithMany("Services")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
.WithMany("Medicines")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Medicine");
b.Navigation("Service");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
.WithMany("Vaccinations")
.HasForeignKey("AnimalId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Animal");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
.WithMany("Visits")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
.WithMany("Visits")
.HasForeignKey("AnimalId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
.WithMany("Animals")
.HasForeignKey("VisitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Animal");
b.Navigation("Visit");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
.WithMany("Visits")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
.WithMany("Services")
.HasForeignKey("VisitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Service");
b.Navigation("Visit");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
{
b.Navigation("Animals");
b.Navigation("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
{
b.Navigation("Medicines");
b.Navigation("Vaccinations");
b.Navigation("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
{
b.Navigation("Animals");
b.Navigation("Services");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
{
b.Navigation("Medicines");
b.Navigation("Services");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
{
b.Navigation("Guidances");
b.Navigation("Medicines");
b.Navigation("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
{
b.Navigation("Animals");
b.Navigation("Services");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,388 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace VetClinicDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Admins",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AdminFIO = 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_Admins", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Pharmacists",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PharmacistFIO = 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_Pharmacists", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Animals",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AdminId = table.Column<int>(type: "int", nullable: false),
VaccinationId = table.Column<int>(type: "int", nullable: false),
AnimalName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Family = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Animals", x => x.Id);
table.ForeignKey(
name: "FK_Animals_Admins_AdminId",
column: x => x.AdminId,
principalTable: "Admins",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Visits",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AdminId = table.Column<int>(type: "int", nullable: false),
NameVisit = table.Column<string>(type: "nvarchar(max)", nullable: false),
DateVisit = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Visits", x => x.Id);
table.ForeignKey(
name: "FK_Visits_Admins_AdminId",
column: x => x.AdminId,
principalTable: "Admins",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Medicines",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MedicineName = table.Column<string>(type: "nvarchar(max)", nullable: false),
PharmacistId = table.Column<int>(type: "int", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Medicines", x => x.Id);
table.ForeignKey(
name: "FK_Medicines_Pharmacists_PharmacistId",
column: x => x.PharmacistId,
principalTable: "Pharmacists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Services",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
PharmacistId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Services", x => x.Id);
table.ForeignKey(
name: "FK_Services_Pharmacists_PharmacistId",
column: x => x.PharmacistId,
principalTable: "Pharmacists",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Vaccinations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AnimalId = table.Column<int>(type: "int", nullable: false),
NameVaccination = table.Column<string>(type: "nvarchar(max)", nullable: false),
CostVaccination = table.Column<double>(type: "float", nullable: false),
DateStamp = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Vaccinations", x => x.Id);
table.ForeignKey(
name: "FK_Vaccinations_Animals_AnimalId",
column: x => x.AnimalId,
principalTable: "Animals",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "VisitAnimals",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AnimalId = table.Column<int>(type: "int", nullable: false),
VisitId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_VisitAnimals", x => x.Id);
table.ForeignKey(
name: "FK_VisitAnimals_Animals_AnimalId",
column: x => x.AnimalId,
principalTable: "Animals",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_VisitAnimals_Visits_VisitId",
column: x => x.VisitId,
principalTable: "Visits",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "MedicineAnimals",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MedicineId = table.Column<int>(type: "int", nullable: false),
AnimalId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MedicineAnimals", x => x.Id);
table.ForeignKey(
name: "FK_MedicineAnimals_Animals_AnimalId",
column: x => x.AnimalId,
principalTable: "Animals",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MedicineAnimals_Medicines_MedicineId",
column: x => x.MedicineId,
principalTable: "Medicines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Guidances",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ServiceId = table.Column<int>(type: "int", nullable: false),
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Guidances", x => x.Id);
table.ForeignKey(
name: "FK_Guidances_Services_ServiceId",
column: x => x.ServiceId,
principalTable: "Services",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ServiceMedicines",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ServiceId = table.Column<int>(type: "int", nullable: false),
MedicineId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ServiceMedicines", x => x.Id);
table.ForeignKey(
name: "FK_ServiceMedicines_Medicines_MedicineId",
column: x => x.MedicineId,
principalTable: "Medicines",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ServiceMedicines_Services_ServiceId",
column: x => x.ServiceId,
principalTable: "Services",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ServiceVisits",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ServiceId = table.Column<int>(type: "int", nullable: false),
VisitId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ServiceVisits", x => x.Id);
table.ForeignKey(
name: "FK_ServiceVisits_Services_ServiceId",
column: x => x.ServiceId,
principalTable: "Services",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ServiceVisits_Visits_VisitId",
column: x => x.VisitId,
principalTable: "Visits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Animals_AdminId",
table: "Animals",
column: "AdminId");
migrationBuilder.CreateIndex(
name: "IX_Guidances_ServiceId",
table: "Guidances",
column: "ServiceId");
migrationBuilder.CreateIndex(
name: "IX_MedicineAnimals_AnimalId",
table: "MedicineAnimals",
column: "AnimalId");
migrationBuilder.CreateIndex(
name: "IX_MedicineAnimals_MedicineId",
table: "MedicineAnimals",
column: "MedicineId");
migrationBuilder.CreateIndex(
name: "IX_Medicines_PharmacistId",
table: "Medicines",
column: "PharmacistId");
migrationBuilder.CreateIndex(
name: "IX_ServiceMedicines_MedicineId",
table: "ServiceMedicines",
column: "MedicineId");
migrationBuilder.CreateIndex(
name: "IX_ServiceMedicines_ServiceId",
table: "ServiceMedicines",
column: "ServiceId");
migrationBuilder.CreateIndex(
name: "IX_Services_PharmacistId",
table: "Services",
column: "PharmacistId");
migrationBuilder.CreateIndex(
name: "IX_ServiceVisits_ServiceId",
table: "ServiceVisits",
column: "ServiceId");
migrationBuilder.CreateIndex(
name: "IX_ServiceVisits_VisitId",
table: "ServiceVisits",
column: "VisitId");
migrationBuilder.CreateIndex(
name: "IX_Vaccinations_AnimalId",
table: "Vaccinations",
column: "AnimalId");
migrationBuilder.CreateIndex(
name: "IX_VisitAnimals_AnimalId",
table: "VisitAnimals",
column: "AnimalId");
migrationBuilder.CreateIndex(
name: "IX_VisitAnimals_VisitId",
table: "VisitAnimals",
column: "VisitId");
migrationBuilder.CreateIndex(
name: "IX_Visits_AdminId",
table: "Visits",
column: "AdminId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Guidances");
migrationBuilder.DropTable(
name: "MedicineAnimals");
migrationBuilder.DropTable(
name: "ServiceMedicines");
migrationBuilder.DropTable(
name: "ServiceVisits");
migrationBuilder.DropTable(
name: "Vaccinations");
migrationBuilder.DropTable(
name: "VisitAnimals");
migrationBuilder.DropTable(
name: "Medicines");
migrationBuilder.DropTable(
name: "Services");
migrationBuilder.DropTable(
name: "Animals");
migrationBuilder.DropTable(
name: "Visits");
migrationBuilder.DropTable(
name: "Pharmacists");
migrationBuilder.DropTable(
name: "Admins");
}
}
}

View File

@ -1,518 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using VetClinicDataBaseImplement;
#nullable disable
namespace VetClinicDataBaseImplement.Migrations
{
[DbContext(typeof(VetClinicDatabase))]
partial class VetClinicDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AdminFIO")
.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("Admins");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<string>("AnimalName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Family")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("VaccinationId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AdminId");
b.ToTable("Animals");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.Property<string>("Text")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ServiceId");
b.ToTable("Guidances");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("MedicineName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("Medicines");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AnimalId")
.HasColumnType("int");
b.Property<int>("MedicineId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AnimalId");
b.HasIndex("MedicineId");
b.ToTable("MedicineAnimals");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", 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>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PharmacistFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Pharmacists");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PharmacistId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ServiceName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("PharmacistId");
b.ToTable("Services");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("MedicineId")
.HasColumnType("int");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MedicineId");
b.HasIndex("ServiceId");
b.ToTable("ServiceMedicines");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AnimalId")
.HasColumnType("int");
b.Property<double>("CostVaccination")
.HasColumnType("float");
b.Property<DateTime?>("DateStamp")
.IsRequired()
.HasColumnType("datetime2");
b.Property<string>("NameVaccination")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AnimalId");
b.ToTable("Vaccinations");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AdminId")
.HasColumnType("int");
b.Property<DateTime>("DateVisit")
.HasColumnType("datetime2");
b.Property<string>("NameVisit")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AdminId");
b.ToTable("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AnimalId")
.HasColumnType("int");
b.Property<int>("VisitId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AnimalId");
b.HasIndex("VisitId");
b.ToTable("VisitAnimals");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ServiceId")
.HasColumnType("int");
b.Property<int>("VisitId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ServiceId");
b.HasIndex("VisitId");
b.ToTable("ServiceVisits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
.WithMany("Animals")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
.WithMany("Guidances")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Service");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Medicines")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
.WithMany("Medicines")
.HasForeignKey("AnimalId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
.WithMany("Animals")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Animal");
b.Navigation("Medicine");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist")
.WithMany("Services")
.HasForeignKey("PharmacistId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Pharmacist");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine")
.WithMany("Services")
.HasForeignKey("MedicineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
.WithMany("Medicines")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Medicine");
b.Navigation("Service");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
.WithMany("Vaccinations")
.HasForeignKey("AnimalId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Animal");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin")
.WithMany("Visits")
.HasForeignKey("AdminId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Admin");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal")
.WithMany("Visits")
.HasForeignKey("AnimalId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
.WithMany("Animals")
.HasForeignKey("VisitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Animal");
b.Navigation("Visit");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b =>
{
b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service")
.WithMany("Visits")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit")
.WithMany("Services")
.HasForeignKey("VisitId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Service");
b.Navigation("Visit");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b =>
{
b.Navigation("Animals");
b.Navigation("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b =>
{
b.Navigation("Medicines");
b.Navigation("Vaccinations");
b.Navigation("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b =>
{
b.Navigation("Animals");
b.Navigation("Services");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b =>
{
b.Navigation("Medicines");
b.Navigation("Services");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b =>
{
b.Navigation("Guidances");
b.Navigation("Medicines");
b.Navigation("Visits");
});
modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b =>
{
b.Navigation("Animals");
b.Navigation("Services");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -18,10 +18,7 @@ namespace VetClinicDataBaseImplement.Models
public int Id { get; set; }
[Required]
public int AdminId { get; set; }
[Required]
public Dictionary<int, IAnimalModel>? _visitAnimals = null;
[Required]
public Dictionary<int, IServiceModel>? _serviceVisits = null;
[Required]
public string NameVisit { get; set; } = string.Empty;
@ -33,8 +30,11 @@ namespace VetClinicDataBaseImplement.Models
[ForeignKey("VisitId")]
public virtual List<VisitService> Services { get; set; } = new();
public virtual Admin Admin { get; set; }
public Dictionary<int, IAnimalModel>? _visitAnimals = null;
public Dictionary<int, IServiceModel>? _serviceVisits = null;
[NotMapped]
public Dictionary<int, IAnimalModel> VisitAnimals
{

View File

@ -8,7 +8,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>