diff --git a/CarpentryWorkshop/CarpentryWorkshop.sln b/CarpentryWorkshop/CarpentryWorkshop.sln index 9d6ab31..b11aa99 100644 --- a/CarpentryWorkshop/CarpentryWorkshop.sln +++ b/CarpentryWorkshop/CarpentryWorkshop.sln @@ -17,9 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarpentryWorkshopFileImplem EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarpentryWorkshopDatabaseImplement", "CarpentryWorkshopDatabaseImplement\CarpentryWorkshopDatabaseImplement.csproj", "{249894CF-B596-4AFD-8EB7-F167056920A1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarpentryWorkshopRestApi", "CarpentryWorkshopRestApi\CarpentryWorkshopRestApi.csproj", "{D9D18CB0-4068-43B6-92F9-85905E53FF95}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarpentryWorkshopRestApi", "CarpentryWorkshopRestApi\CarpentryWorkshopRestApi.csproj", "{D9D18CB0-4068-43B6-92F9-85905E53FF95}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarpentryWorkshopClientApp", "CarpentryWorkshopClientApp\CarpentryWorkshopClientApp.csproj", "{69DE353E-934B-4CBA-89C0-BC253741F810}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarpentryWorkshopClientApp", "CarpentryWorkshopClientApp\CarpentryWorkshopClientApp.csproj", "{69DE353E-934B-4CBA-89C0-BC253741F810}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/CarpentryWorkshopDatabaseImplement.csproj b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/CarpentryWorkshopDatabaseImplement.csproj index 96db0ca..59417c2 100644 --- a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/CarpentryWorkshopDatabaseImplement.csproj +++ b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/CarpentryWorkshopDatabaseImplement.csproj @@ -20,4 +20,8 @@ + + + + diff --git a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240313050649_InitialCreate.Designer.cs b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240313050649_InitialCreate.Designer.cs deleted file mode 100644 index 8691b14..0000000 --- a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240313050649_InitialCreate.Designer.cs +++ /dev/null @@ -1,171 +0,0 @@ -// -using System; -using CarpentryWorkshopDatabaseImplement; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace CarpentryWorkshopDatabaseImplement.Migrations -{ - [DbContext(typeof(CarpentryWorkshopDatabase))] - [Migration("20240313050649_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("CarpentryWorkshopDatabaseImplement.Models.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("CarpentryWorkshopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.Property("WoodId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("WoodId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Wood", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("WoodName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Woods"); - }); - - modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.WoodComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("WoodId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("WoodId"); - - b.ToTable("WoodComponents"); - }); - - modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Order", b => - { - b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Wood", "Wood") - .WithMany("Orders") - .HasForeignKey("WoodId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Wood"); - }); - - modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.WoodComponent", b => - { - b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Component", "Component") - .WithMany("WoodComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Wood", "Wood") - .WithMany("Components") - .HasForeignKey("WoodId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Wood"); - }); - - modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Component", b => - { - b.Navigation("WoodComponents"); - }); - - modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Wood", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.cs b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.cs deleted file mode 100644 index ceaadb3..0000000 --- a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.cs +++ /dev/null @@ -1,69 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace CarpentryWorkshopDatabaseImplement.Migrations -{ - /// - public partial class MbLab5 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); - migrationBuilder.AddColumn( - name: "ClientId", - table: "Orders", - type: "int", - nullable: false, - defaultValue: 0); - - migrationBuilder.CreateTable( - name: "Clients", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = 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_Clients", x => x.Id); - }); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ClientId", - table: "Orders", - column: "ClientId"); - - migrationBuilder.AddForeignKey( - name: "FK_Orders_Clients_ClientId", - table: "Orders", - column: "ClientId", - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Orders_Clients_ClientId", - table: "Orders"); - - migrationBuilder.DropTable( - name: "Clients"); - - migrationBuilder.DropIndex( - name: "IX_Orders_ClientId", - table: "Orders"); - - migrationBuilder.DropColumn( - name: "ClientId", - table: "Orders"); - } - } -} diff --git a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.Designer.cs b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240505132850_InitialCreate.Designer.cs similarity index 81% rename from CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.Designer.cs rename to CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240505132850_InitialCreate.Designer.cs index 02381f2..dc91bfe 100644 --- a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240419085157_MbLab5.Designer.cs +++ b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240505132850_InitialCreate.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace CarpentryWorkshopDatabaseImplement.Migrations { [DbContext(typeof(CarpentryWorkshopDatabase))] - [Migration("20240419085157_MbLab5")] - partial class MbLab5 + [Migration("20240505132850_InitialCreate")] + partial class InitialCreate { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -70,6 +70,33 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.ToTable("Components"); }); + modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.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("CarpentryWorkshopDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -90,6 +117,9 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("Status") .HasColumnType("int"); @@ -103,6 +133,8 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("WoodId"); b.ToTable("Orders"); @@ -162,6 +194,10 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Wood", "Wood") .WithMany("Orders") .HasForeignKey("WoodId") @@ -170,6 +206,8 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Wood"); }); @@ -202,6 +240,11 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.Navigation("WoodComponents"); }); + modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Wood", b => { b.Navigation("Components"); diff --git a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240313050649_InitialCreate.cs b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240505132850_InitialCreate.cs similarity index 64% rename from CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240313050649_InitialCreate.cs rename to CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240505132850_InitialCreate.cs index 709f7b0..d705df7 100644 --- a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240313050649_InitialCreate.cs +++ b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/20240505132850_InitialCreate.cs @@ -11,6 +11,21 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientFIO = 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_Clients", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Components", columns: table => new @@ -25,6 +40,22 @@ namespace CarpentryWorkshopDatabaseImplement.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), + WorkExperience = table.Column(type: "int", nullable: false), + Qualification = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Woods", columns: table => new @@ -46,6 +77,8 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), WoodId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false), + ImplementerId = table.Column(type: "int", nullable: true), Count = table.Column(type: "int", nullable: false), Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), @@ -55,6 +88,17 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Clients_ClientId", + column: x => x.ClientId, + 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_Woods_WoodId", column: x => x.WoodId, @@ -90,6 +134,16 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + 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_WoodId", table: "Orders", @@ -115,6 +169,12 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations migrationBuilder.DropTable( name: "WoodComponents"); + migrationBuilder.DropTable( + name: "Clients"); + + migrationBuilder.DropTable( + name: "Implementers"); + migrationBuilder.DropTable( name: "Components"); diff --git a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/CarpentryWorkshopDatabaseModelSnapshot.cs b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/CarpentryWorkshopDatabaseModelSnapshot.cs index f285b97..af33fb7 100644 --- a/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/CarpentryWorkshopDatabaseModelSnapshot.cs +++ b/CarpentryWorkshop/CarpentryWorkshopDatabaseImplement/Migrations/CarpentryWorkshopDatabaseModelSnapshot.cs @@ -44,7 +44,7 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.HasKey("Id"); - b.ToTable("Clients", (string)null); + b.ToTable("Clients"); }); modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Component", b => @@ -64,7 +64,34 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.HasKey("Id"); - b.ToTable("Components", (string)null); + b.ToTable("Components"); + }); + + modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.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("CarpentryWorkshopDatabaseImplement.Models.Order", b => @@ -87,6 +114,9 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("Status") .HasColumnType("int"); @@ -100,9 +130,11 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("WoodId"); - b.ToTable("Orders", (string)null); + b.ToTable("Orders"); }); modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Wood", b => @@ -122,7 +154,7 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.HasKey("Id"); - b.ToTable("Woods", (string)null); + b.ToTable("Woods"); }); modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.WoodComponent", b => @@ -148,7 +180,7 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.HasIndex("WoodId"); - b.ToTable("WoodComponents", (string)null); + b.ToTable("WoodComponents"); }); modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Order", b => @@ -159,6 +191,10 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("CarpentryWorkshopDatabaseImplement.Models.Wood", "Wood") .WithMany("Orders") .HasForeignKey("WoodId") @@ -167,6 +203,8 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Wood"); }); @@ -199,6 +237,11 @@ namespace CarpentryWorkshopDatabaseImplement.Migrations b.Navigation("WoodComponents"); }); + modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("CarpentryWorkshopDatabaseImplement.Models.Wood", b => { b.Navigation("Components");