From feda914c490305add7f45a370bb238dd711258f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=BE=D1=84=D1=8C=D1=8F=20=D0=AF=D0=BA=D0=BE=D0=B1?= =?UTF-8?q?=D1=87=D1=83=D0=BA?= Date: Thu, 2 May 2024 14:30:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20240502102425_InitialCreate.Designer.cs | 545 ++++++++++++++++++ .../20240502102425_InitialCreate.cs | 413 +++++++++++++ .../LawCompanyDatabaseModelSnapshot.cs | 542 +++++++++++++++++ 3 files changed, 1500 insertions(+) create mode 100644 LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.Designer.cs create mode 100644 LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.cs create mode 100644 LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs diff --git a/LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.Designer.cs b/LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.Designer.cs new file mode 100644 index 0000000..24f1e7f --- /dev/null +++ b/LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.Designer.cs @@ -0,0 +1,545 @@ +// +using System; +using LawCompanyDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace LawCompanyDatabaseImplement.Migrations +{ + [DbContext(typeof(LawCompanyDatabase))] + [Migration("20240502102425_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.17") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CaseType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.ToTable("Cases"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("int"); + + b.Property("ClientId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("ClientId"); + + b.ToTable("CaseClients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("int"); + + b.Property("ConsultationDate") + .HasColumnType("datetime2"); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("GuarantorId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("GuarantorId"); + + b.ToTable("Consultations"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConsultationId") + .HasColumnType("int"); + + b.Property("LawyerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConsultationId"); + + b.HasIndex("LawyerId"); + + b.ToTable("ConsultationLawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Executors"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Guarantors"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GuarantorId") + .HasColumnType("int"); + + b.Property("HearingDate") + .HasColumnType("datetime2"); + + b.Property("Judge") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GuarantorId"); + + b.ToTable("Hearings"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HearingId") + .HasColumnType("int"); + + b.Property("LawyerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("HearingId"); + + b.HasIndex("LawyerId"); + + b.ToTable("HearingLawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GuarantorId") + .HasColumnType("int"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GuarantorId"); + + b.ToTable("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("HearingId") + .HasColumnType("int"); + + b.Property("VisitDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.HasIndex("HearingId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("VisitId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitClients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Cases") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") + .WithMany("Clients") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") + .WithMany("CaseClients") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Clients") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") + .WithMany() + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Consultations") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Consultation", "Consultation") + .WithMany("Lawyers") + .HasForeignKey("ConsultationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") + .WithMany("ConsultationLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Consultation"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Hearings") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") + .WithMany("Lawyers") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") + .WithMany("HearingLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hearing"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Lawyers") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Visits") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") + .WithMany() + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hearing"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") + .WithMany("ClientVisits") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Visit", "Visit") + .WithMany("Clients") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.Navigation("Clients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.Navigation("CaseClients"); + + b.Navigation("ClientVisits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => + { + b.Navigation("Cases"); + + b.Navigation("Clients"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => + { + b.Navigation("Consultations"); + + b.Navigation("Hearings"); + + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.Navigation("ConsultationLawyers"); + + b.Navigation("HearingLawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.Navigation("Clients"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.cs b/LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.cs new file mode 100644 index 0000000..2529ce0 --- /dev/null +++ b/LawCompany/LawCompanyDatabaseImplement/Migrations/20240502102425_InitialCreate.cs @@ -0,0 +1,413 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LawCompanyDatabaseImplement.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Executors", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Executors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Guarantors", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Guarantors", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Cases", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + CaseType = table.Column(type: "nvarchar(max)", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateImplement = table.Column(type: "datetime2", nullable: true), + Status = table.Column(type: "int", nullable: false), + ExecutorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cases", x => x.Id); + table.ForeignKey( + name: "FK_Cases_Executors_ExecutorId", + column: x => x.ExecutorId, + principalTable: "Executors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Phone = table.Column(type: "nvarchar(max)", nullable: false), + ExecutorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + table.ForeignKey( + name: "FK_Clients_Executors_ExecutorId", + column: x => x.ExecutorId, + principalTable: "Executors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Hearings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + HearingDate = table.Column(type: "datetime2", nullable: false), + Judge = table.Column(type: "nvarchar(max)", nullable: false), + GuarantorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Hearings", x => x.Id); + table.ForeignKey( + name: "FK_Hearings_Guarantors_GuarantorId", + column: x => x.GuarantorId, + principalTable: "Guarantors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Lawyers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Phone = table.Column(type: "nvarchar(max)", nullable: false), + GuarantorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Lawyers", x => x.Id); + table.ForeignKey( + name: "FK_Lawyers_Guarantors_GuarantorId", + column: x => x.GuarantorId, + principalTable: "Guarantors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Consultations", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Cost = table.Column(type: "float", nullable: false), + ConsultationDate = table.Column(type: "datetime2", nullable: false), + CaseId = table.Column(type: "int", nullable: false), + GuarantorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Consultations", x => x.Id); + table.ForeignKey( + name: "FK_Consultations_Cases_CaseId", + column: x => x.CaseId, + principalTable: "Cases", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Consultations_Guarantors_GuarantorId", + column: x => x.GuarantorId, + principalTable: "Guarantors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CaseClients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CaseId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CaseClients", x => x.Id); + table.ForeignKey( + name: "FK_CaseClients_Cases_CaseId", + column: x => x.CaseId, + principalTable: "Cases", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CaseClients_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "Visits", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + VisitDate = table.Column(type: "datetime2", nullable: false), + HearingId = table.Column(type: "int", nullable: false), + ExecutorId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Visits", x => x.Id); + table.ForeignKey( + name: "FK_Visits_Executors_ExecutorId", + column: x => x.ExecutorId, + principalTable: "Executors", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Visits_Hearings_HearingId", + column: x => x.HearingId, + principalTable: "Hearings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "HearingLawyers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + HearingId = table.Column(type: "int", nullable: false), + LawyerId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_HearingLawyers", x => x.Id); + table.ForeignKey( + name: "FK_HearingLawyers_Hearings_HearingId", + column: x => x.HearingId, + principalTable: "Hearings", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_HearingLawyers_Lawyers_LawyerId", + column: x => x.LawyerId, + principalTable: "Lawyers", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "ConsultationLawyers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ConsultationId = table.Column(type: "int", nullable: false), + LawyerId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ConsultationLawyers", x => x.Id); + table.ForeignKey( + name: "FK_ConsultationLawyers_Consultations_ConsultationId", + column: x => x.ConsultationId, + principalTable: "Consultations", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ConsultationLawyers_Lawyers_LawyerId", + column: x => x.LawyerId, + principalTable: "Lawyers", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateTable( + name: "VisitClients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientId = table.Column(type: "int", nullable: false), + VisitId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VisitClients", x => x.Id); + table.ForeignKey( + name: "FK_VisitClients_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_VisitClients_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "Id", + onDelete: ReferentialAction.NoAction); + }); + + migrationBuilder.CreateIndex( + name: "IX_CaseClients_CaseId", + table: "CaseClients", + column: "CaseId"); + + migrationBuilder.CreateIndex( + name: "IX_CaseClients_ClientId", + table: "CaseClients", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_Cases_ExecutorId", + table: "Cases", + column: "ExecutorId"); + + migrationBuilder.CreateIndex( + name: "IX_Clients_ExecutorId", + table: "Clients", + column: "ExecutorId"); + + migrationBuilder.CreateIndex( + name: "IX_ConsultationLawyers_ConsultationId", + table: "ConsultationLawyers", + column: "ConsultationId"); + + migrationBuilder.CreateIndex( + name: "IX_ConsultationLawyers_LawyerId", + table: "ConsultationLawyers", + column: "LawyerId"); + + migrationBuilder.CreateIndex( + name: "IX_Consultations_CaseId", + table: "Consultations", + column: "CaseId"); + + migrationBuilder.CreateIndex( + name: "IX_Consultations_GuarantorId", + table: "Consultations", + column: "GuarantorId"); + + migrationBuilder.CreateIndex( + name: "IX_HearingLawyers_HearingId", + table: "HearingLawyers", + column: "HearingId"); + + migrationBuilder.CreateIndex( + name: "IX_HearingLawyers_LawyerId", + table: "HearingLawyers", + column: "LawyerId"); + + migrationBuilder.CreateIndex( + name: "IX_Hearings_GuarantorId", + table: "Hearings", + column: "GuarantorId"); + + migrationBuilder.CreateIndex( + name: "IX_Lawyers_GuarantorId", + table: "Lawyers", + column: "GuarantorId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitClients_ClientId", + table: "VisitClients", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitClients_VisitId", + table: "VisitClients", + column: "VisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Visits_ExecutorId", + table: "Visits", + column: "ExecutorId"); + + migrationBuilder.CreateIndex( + name: "IX_Visits_HearingId", + table: "Visits", + column: "HearingId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CaseClients"); + + migrationBuilder.DropTable( + name: "ConsultationLawyers"); + + migrationBuilder.DropTable( + name: "HearingLawyers"); + + migrationBuilder.DropTable( + name: "VisitClients"); + + migrationBuilder.DropTable( + name: "Consultations"); + + migrationBuilder.DropTable( + name: "Lawyers"); + + migrationBuilder.DropTable( + name: "Clients"); + + migrationBuilder.DropTable( + name: "Visits"); + + migrationBuilder.DropTable( + name: "Cases"); + + migrationBuilder.DropTable( + name: "Hearings"); + + migrationBuilder.DropTable( + name: "Executors"); + + migrationBuilder.DropTable( + name: "Guarantors"); + } + } +} diff --git a/LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs b/LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs new file mode 100644 index 0000000..0a56764 --- /dev/null +++ b/LawCompany/LawCompanyDatabaseImplement/Migrations/LawCompanyDatabaseModelSnapshot.cs @@ -0,0 +1,542 @@ +// +using System; +using LawCompanyDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace LawCompanyDatabaseImplement.Migrations +{ + [DbContext(typeof(LawCompanyDatabase))] + partial class LawCompanyDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.17") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CaseType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.ToTable("Cases"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("int"); + + b.Property("ClientId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("ClientId"); + + b.ToTable("CaseClients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CaseId") + .HasColumnType("int"); + + b.Property("ConsultationDate") + .HasColumnType("datetime2"); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("GuarantorId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CaseId"); + + b.HasIndex("GuarantorId"); + + b.ToTable("Consultations"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ConsultationId") + .HasColumnType("int"); + + b.Property("LawyerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ConsultationId"); + + b.HasIndex("LawyerId"); + + b.ToTable("ConsultationLawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Executors"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Guarantors"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("GuarantorId") + .HasColumnType("int"); + + b.Property("HearingDate") + .HasColumnType("datetime2"); + + b.Property("Judge") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GuarantorId"); + + b.ToTable("Hearings"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HearingId") + .HasColumnType("int"); + + b.Property("LawyerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("HearingId"); + + b.HasIndex("LawyerId"); + + b.ToTable("HearingLawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GuarantorId") + .HasColumnType("int"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("GuarantorId"); + + b.ToTable("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExecutorId") + .HasColumnType("int"); + + b.Property("HearingId") + .HasColumnType("int"); + + b.Property("VisitDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ExecutorId"); + + b.HasIndex("HearingId"); + + b.ToTable("Visits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("VisitId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("VisitId"); + + b.ToTable("VisitClients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Cases") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.CaseClient", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") + .WithMany("Clients") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") + .WithMany("CaseClients") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Client"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Clients") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Case", "Case") + .WithMany() + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Consultations") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.ConsultationLawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Consultation", "Consultation") + .WithMany("Lawyers") + .HasForeignKey("ConsultationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") + .WithMany("ConsultationLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Consultation"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Hearings") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.HearingLawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") + .WithMany("Lawyers") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Lawyer", "Lawyer") + .WithMany("HearingLawyers") + .HasForeignKey("LawyerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hearing"); + + b.Navigation("Lawyer"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Guarantor", null) + .WithMany("Lawyers") + .HasForeignKey("GuarantorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Executor", null) + .WithMany("Visits") + .HasForeignKey("ExecutorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Hearing", "Hearing") + .WithMany() + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hearing"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.VisitClient", b => + { + b.HasOne("LawCompanyDatabaseImplement.Models.Client", "Client") + .WithMany("ClientVisits") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawCompanyDatabaseImplement.Models.Visit", "Visit") + .WithMany("Clients") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Case", b => + { + b.Navigation("Clients"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Client", b => + { + b.Navigation("CaseClients"); + + b.Navigation("ClientVisits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Consultation", b => + { + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Executor", b => + { + b.Navigation("Cases"); + + b.Navigation("Clients"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Guarantor", b => + { + b.Navigation("Consultations"); + + b.Navigation("Hearings"); + + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Hearing", b => + { + b.Navigation("Lawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Lawyer", b => + { + b.Navigation("ConsultationLawyers"); + + b.Navigation("HearingLawyers"); + }); + + modelBuilder.Entity("LawCompanyDatabaseImplement.Models.Visit", b => + { + b.Navigation("Clients"); + }); +#pragma warning restore 612, 618 + } + } +}