diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240421191737_InitialCreate1.Designer.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240421191737_InitialCreate1.Designer.cs deleted file mode 100644 index 48fdfe9..0000000 --- a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240421191737_InitialCreate1.Designer.cs +++ /dev/null @@ -1,214 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using RenovationWorkDatabaseImplement; - -#nullable disable - -namespace RenovationWorkDatabaseImplement_.Migrations -{ - [DbContext(typeof(RenovationWorkDatabase))] - [Migration("20240421191737_InitialCreate1")] - partial class InitialCreate1 - { - /// - 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("RenovationWorkDatabaseImplement.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("RepairId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("RepairId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("RepairName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Repairs"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("RepairId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("RepairId"); - - b.ToTable("RepairComponents"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b => - { - b.HasOne("RenovationWorkDatabaseImplement.Models.Client", "Client") - .WithMany("Orders") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair") - .WithMany("Orders") - .HasForeignKey("RepairId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - - b.Navigation("Repair"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b => - { - b.HasOne("RenovationWorkDatabaseImplement.Component", "Component") - .WithMany("RepairComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair") - .WithMany("Components") - .HasForeignKey("RepairId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Repair"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Component", b => - { - b.Navigation("RepairComponents"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs deleted file mode 100644 index 387a4e5..0000000 --- a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs +++ /dev/null @@ -1,257 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using RenovationWorkDatabaseImplement; - -#nullable disable - -namespace RenovationWorkDatabaseImplement_.Migrations -{ - [DbContext(typeof(RenovationWorkDatabase))] - [Migration("20240501150513_addingImplementors")] - partial class addingImplementors - { - /// - 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("RenovationWorkDatabaseImplement.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ImplementerFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Qualification") - .HasColumnType("int"); - - b.Property("WorkExperience") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Implementers"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("ImplementerId") - .HasColumnType("int"); - - b.Property("RepairId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ImplementerId"); - - b.HasIndex("RepairId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("RepairName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Repairs"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("RepairId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("RepairId"); - - b.ToTable("RepairComponents"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b => - { - b.HasOne("RenovationWorkDatabaseImplement.Models.Client", "Client") - .WithMany("Orders") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("RenovationWorkDatabaseImplement.Models.Implementer", "Implementer") - .WithMany("Orders") - .HasForeignKey("ImplementerId"); - - b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair") - .WithMany("Orders") - .HasForeignKey("RepairId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - - b.Navigation("Implementer"); - - b.Navigation("Repair"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b => - { - b.HasOne("RenovationWorkDatabaseImplement.Component", "Component") - .WithMany("RepairComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair") - .WithMany("Components") - .HasForeignKey("RepairId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Repair"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Component", b => - { - b.Navigation("RepairComponents"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.cs deleted file mode 100644 index a0dfbbb..0000000 --- a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace RenovationWorkDatabaseImplement_.Migrations -{ - /// - public partial class addingImplementors : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ImplementerId", - table: "Orders", - type: "int", - nullable: true); - - migrationBuilder.CreateTable( - name: "Implementers", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false), - Qualification = table.Column(type: "int", nullable: false), - WorkExperience = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Implementers", x => x.Id); - }); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ImplementerId", - table: "Orders", - column: "ImplementerId"); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Implementers_ImplementerId", - table: "Orders", - column: "ImplementerId", - principalTable: "Implementers", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Orders_Implementers_ImplementerId", - table: "Orders"); - - migrationBuilder.DropTable( - name: "Implementers"); - - migrationBuilder.DropIndex( - name: "IX_Orders_ImplementerId", - table: "Orders"); - - migrationBuilder.DropColumn( - name: "ImplementerId", - table: "Orders"); - } - } -} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240516094211_InitialCreateMail.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240516094211_InitialCreateMail.cs deleted file mode 100644 index ff4f8b1..0000000 --- a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240516094211_InitialCreateMail.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace RenovationWorkDatabaseImplement_.Migrations -{ - /// - public partial class InitialCreateMail : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240516094211_InitialCreateMail.Designer.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.Designer.cs similarity index 99% rename from RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240516094211_InitialCreateMail.Designer.cs rename to RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.Designer.cs index 5d1af52..a164d3b 100644 --- a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240516094211_InitialCreateMail.Designer.cs +++ b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.Designer.cs @@ -12,8 +12,8 @@ using RenovationWorkDatabaseImplement; namespace RenovationWorkDatabaseImplement_.Migrations { [DbContext(typeof(RenovationWorkDatabase))] - [Migration("20240516094211_InitialCreateMail")] - partial class InitialCreateMail + [Migration("20240519185748_InitialCreateMail123")] + partial class InitialCreateMail123 { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240421191737_InitialCreate1.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.cs similarity index 69% rename from RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240421191737_InitialCreate1.cs rename to RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.cs index 42bb756..364d443 100644 --- a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240421191737_InitialCreate1.cs +++ b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240519185748_InitialCreateMail123.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace RenovationWorkDatabaseImplement_.Migrations { /// - public partial class InitialCreate1 : Migration + public partial class InitialCreateMail123 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -40,6 +40,22 @@ namespace RenovationWorkDatabaseImplement_.Migrations table.PrimaryKey("PK_Components", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Qualification = table.Column(type: "int", nullable: false), + WorkExperience = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Repairs", columns: table => new @@ -54,6 +70,27 @@ namespace RenovationWorkDatabaseImplement_.Migrations table.PrimaryKey("PK_Repairs", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Messages", + columns: table => new + { + MessageId = table.Column(type: "nvarchar(450)", nullable: false), + ClientId = table.Column(type: "int", nullable: true), + SenderName = table.Column(type: "nvarchar(max)", nullable: false), + DateDelivery = table.Column(type: "datetime2", nullable: false), + Subject = table.Column(type: "nvarchar(max)", nullable: false), + Body = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Messages", x => x.MessageId); + table.ForeignKey( + name: "FK_Messages_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id"); + }); + migrationBuilder.CreateTable( name: "Orders", columns: table => new @@ -66,7 +103,8 @@ namespace RenovationWorkDatabaseImplement_.Migrations Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(type: "datetime2", nullable: true) + DateImplement = table.Column(type: "datetime2", nullable: true), + ImplementerId = table.Column(type: "int", nullable: true) }, constraints: table => { @@ -77,6 +115,11 @@ namespace RenovationWorkDatabaseImplement_.Migrations principalTable: "Clients", principalColumn: "Id", onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + column: x => x.ImplementerId, + principalTable: "Implementers", + principalColumn: "Id"); table.ForeignKey( name: "FK_Orders_Repairs_RepairId", column: x => x.RepairId, @@ -112,11 +155,21 @@ namespace RenovationWorkDatabaseImplement_.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateIndex( + name: "IX_Messages_ClientId", + table: "Messages", + column: "ClientId"); + migrationBuilder.CreateIndex( name: "IX_Orders_ClientId", table: "Orders", column: "ClientId"); + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + migrationBuilder.CreateIndex( name: "IX_Orders_RepairId", table: "Orders", @@ -136,6 +189,9 @@ namespace RenovationWorkDatabaseImplement_.Migrations /// protected override void Down(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "Messages"); + migrationBuilder.DropTable( name: "Orders"); @@ -145,6 +201,9 @@ namespace RenovationWorkDatabaseImplement_.Migrations migrationBuilder.DropTable( name: "Clients"); + migrationBuilder.DropTable( + name: "Implementers"); + migrationBuilder.DropTable( name: "Components"); diff --git a/RenovationWork/RenovationWorkDatabaseImplement/RenovationWorkDatabase.cs b/RenovationWork/RenovationWorkDatabaseImplement/RenovationWorkDatabase.cs index 9a815a6..3a25bf2 100644 --- a/RenovationWork/RenovationWorkDatabaseImplement/RenovationWorkDatabase.cs +++ b/RenovationWork/RenovationWorkDatabaseImplement/RenovationWorkDatabase.cs @@ -15,7 +15,7 @@ namespace RenovationWorkDatabaseImplement { if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=RenovationWorkDatabase_7.1;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=RenovationWorkDatabase_7.2;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); }