diff --git a/HardwareShop/HardwareShopBusinessLogic/HardwareShopBusinessLogic.csproj b/HardwareShop/HardwareShopBusinessLogic/HardwareShopBusinessLogic.csproj
index 132c02c..cf5b579 100644
--- a/HardwareShop/HardwareShopBusinessLogic/HardwareShopBusinessLogic.csproj
+++ b/HardwareShop/HardwareShopBusinessLogic/HardwareShopBusinessLogic.csproj
@@ -6,4 +6,8 @@
enable
+
+
+
+
diff --git a/HardwareShop/HardwareShopContracts/HardwareShopContracts.csproj b/HardwareShop/HardwareShopContracts/HardwareShopContracts.csproj
index 615c25a..21676d4 100644
--- a/HardwareShop/HardwareShopContracts/HardwareShopContracts.csproj
+++ b/HardwareShop/HardwareShopContracts/HardwareShopContracts.csproj
@@ -6,6 +6,10 @@
enable
+
+
+
+
diff --git a/HardwareShop/HardwareShopDataModels/HardwareShopDataModels.csproj b/HardwareShop/HardwareShopDataModels/HardwareShopDataModels.csproj
index 132c02c..cf5b579 100644
--- a/HardwareShop/HardwareShopDataModels/HardwareShopDataModels.csproj
+++ b/HardwareShop/HardwareShopDataModels/HardwareShopDataModels.csproj
@@ -6,4 +6,8 @@
enable
+
+
+
+
diff --git a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs
index 42af9dd..bd32b1e 100644
--- a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs
+++ b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabase.cs
@@ -12,7 +12,7 @@ namespace HardwareShopDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
- optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D8KMQQU\SQLEXPRESS;Initial Catalog=HardwareShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
+ optionsBuilder.UseNpgsql("Host=192.168.0.101;Port=5432;Database=Computer_Hardware_Store;Username=user;Password=12345");
}
base.OnConfiguring(optionsBuilder);
}
diff --git a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj
index 7a7dd94..a308b73 100644
--- a/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj
+++ b/HardwareShop/HardwareShopDatabaseImplement/HardwareShopDatabaseImplement.csproj
@@ -19,6 +19,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141411_InitMigration.Designer.cs b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141411_InitMigration.Designer.cs
new file mode 100644
index 0000000..67a56b1
--- /dev/null
+++ b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141411_InitMigration.Designer.cs
@@ -0,0 +1,470 @@
+//
+using System;
+using HardwareShopDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace HardwareShopDatabaseImplement.Migrations
+{
+ [DbContext(typeof(HardwareShopDatabase))]
+ [Migration("20230401141411_InitMigration")]
+ partial class InitMigration
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.4")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
+ {
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("BuildId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("ComponentId", "BuildId");
+
+ b.HasIndex("BuildId");
+
+ b.ToTable("BuildsComponents");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
+ {
+ b.Property("GoodId")
+ .HasColumnType("integer");
+
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("GoodId", "ComponentId");
+
+ b.HasIndex("ComponentId");
+
+ b.ToTable("GoodComponents");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
+ {
+ b.Property("PurchaseId")
+ .HasColumnType("integer");
+
+ b.Property("BuildId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("PurchaseId", "BuildId");
+
+ b.HasIndex("BuildId");
+
+ b.ToTable("PurchasesBuilds");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
+ {
+ b.Property("PurchaseId")
+ .HasColumnType("integer");
+
+ b.Property("GoodId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("PurchaseId", "GoodId");
+
+ b.HasIndex("GoodId");
+
+ b.ToTable("PurchasesGoods");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Cost")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("GoodName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Goods");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("DateCreate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateImplement")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("GoodId")
+ .HasColumnType("integer");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GoodId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Login")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Role")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("BuildName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("numeric");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Builds");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("BuildId")
+ .HasColumnType("integer");
+
+ b.Property("Text")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("BuildId");
+
+ b.ToTable("Comments");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("DatePurchase")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("PurchaseStatus")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("numeric");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Purchases");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
+ .WithMany("Components")
+ .HasForeignKey("BuildId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
+ .WithMany()
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Build");
+
+ b.Navigation("Component");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
+ .WithMany("GoodComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
+ .WithMany("Components")
+ .HasForeignKey("GoodId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Good");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
+ .WithMany("Purchases")
+ .HasForeignKey("BuildId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
+ .WithMany("Builds")
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Build");
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
+ .WithMany()
+ .HasForeignKey("GoodId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
+ .WithMany("Goods")
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Good");
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
+ .WithMany("Orders")
+ .HasForeignKey("GoodId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Good");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
+ .WithMany("Comments")
+ .HasForeignKey("BuildId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Build");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
+ {
+ b.Navigation("GoodComponents");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
+ {
+ b.Navigation("Comments");
+
+ b.Navigation("Components");
+
+ b.Navigation("Purchases");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
+ {
+ b.Navigation("Builds");
+
+ b.Navigation("Goods");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141411_InitMigration.cs b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141411_InitMigration.cs
new file mode 100644
index 0000000..5e87b90
--- /dev/null
+++ b/HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401141411_InitMigration.cs
@@ -0,0 +1,360 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace HardwareShopDatabaseImplement.Migrations
+{
+ ///
+ public partial class InitMigration : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Users",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Login = table.Column(type: "text", nullable: false),
+ Email = table.Column(type: "text", nullable: false),
+ Password = table.Column(type: "text", nullable: false),
+ Role = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Users", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Builds",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Price = table.Column(type: "numeric", nullable: false),
+ BuildName = table.Column(type: "text", nullable: false),
+ UserId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Builds", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Builds_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Components",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ ComponentName = table.Column(type: "text", nullable: false),
+ Cost = table.Column(type: "double precision", nullable: false),
+ UserId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Components", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Components_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Goods",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ GoodName = table.Column(type: "text", nullable: false),
+ Price = table.Column(type: "double precision", nullable: false),
+ UserId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Goods", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Goods_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Purchases",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Sum = table.Column(type: "numeric", nullable: false),
+ PurchaseStatus = table.Column(type: "integer", nullable: false),
+ DatePurchase = table.Column(type: "timestamp with time zone", nullable: true),
+ UserId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Purchases", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Purchases_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Comments",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ Text = table.Column(type: "text", nullable: false),
+ BuildId = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Comments", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Comments_Builds_BuildId",
+ column: x => x.BuildId,
+ principalTable: "Builds",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "BuildsComponents",
+ columns: table => new
+ {
+ BuildId = table.Column(type: "integer", nullable: false),
+ ComponentId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_BuildsComponents", x => new { x.ComponentId, x.BuildId });
+ table.ForeignKey(
+ name: "FK_BuildsComponents_Builds_BuildId",
+ column: x => x.BuildId,
+ principalTable: "Builds",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_BuildsComponents_Components_ComponentId",
+ column: x => x.ComponentId,
+ principalTable: "Components",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "GoodComponents",
+ columns: table => new
+ {
+ GoodId = table.Column(type: "integer", nullable: false),
+ ComponentId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_GoodComponents", x => new { x.GoodId, x.ComponentId });
+ table.ForeignKey(
+ name: "FK_GoodComponents_Components_ComponentId",
+ column: x => x.ComponentId,
+ principalTable: "Components",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_GoodComponents_Goods_GoodId",
+ column: x => x.GoodId,
+ principalTable: "Goods",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Orders",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ GoodId = table.Column(type: "integer", nullable: false),
+ UserId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false),
+ Sum = table.Column(type: "double precision", nullable: false),
+ Status = table.Column(type: "integer", nullable: false),
+ DateCreate = table.Column(type: "timestamp with time zone", nullable: false),
+ DateImplement = table.Column(type: "timestamp with time zone", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Orders", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Orders_Goods_GoodId",
+ column: x => x.GoodId,
+ principalTable: "Goods",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Orders_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "PurchasesBuilds",
+ columns: table => new
+ {
+ BuildId = table.Column(type: "integer", nullable: false),
+ PurchaseId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_PurchasesBuilds", x => new { x.PurchaseId, x.BuildId });
+ table.ForeignKey(
+ name: "FK_PurchasesBuilds_Builds_BuildId",
+ column: x => x.BuildId,
+ principalTable: "Builds",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_PurchasesBuilds_Purchases_PurchaseId",
+ column: x => x.PurchaseId,
+ principalTable: "Purchases",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "PurchasesGoods",
+ columns: table => new
+ {
+ PurchaseId = table.Column(type: "integer", nullable: false),
+ GoodId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_PurchasesGoods", x => new { x.PurchaseId, x.GoodId });
+ table.ForeignKey(
+ name: "FK_PurchasesGoods_Goods_GoodId",
+ column: x => x.GoodId,
+ principalTable: "Goods",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_PurchasesGoods_Purchases_PurchaseId",
+ column: x => x.PurchaseId,
+ principalTable: "Purchases",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Builds_UserId",
+ table: "Builds",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_BuildsComponents_BuildId",
+ table: "BuildsComponents",
+ column: "BuildId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Comments_BuildId",
+ table: "Comments",
+ column: "BuildId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Components_UserId",
+ table: "Components",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GoodComponents_ComponentId",
+ table: "GoodComponents",
+ column: "ComponentId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Goods_UserId",
+ table: "Goods",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_GoodId",
+ table: "Orders",
+ column: "GoodId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_UserId",
+ table: "Orders",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Purchases_UserId",
+ table: "Purchases",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_PurchasesBuilds_BuildId",
+ table: "PurchasesBuilds",
+ column: "BuildId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_PurchasesGoods_GoodId",
+ table: "PurchasesGoods",
+ column: "GoodId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "BuildsComponents");
+
+ migrationBuilder.DropTable(
+ name: "Comments");
+
+ migrationBuilder.DropTable(
+ name: "GoodComponents");
+
+ migrationBuilder.DropTable(
+ name: "Orders");
+
+ migrationBuilder.DropTable(
+ name: "PurchasesBuilds");
+
+ migrationBuilder.DropTable(
+ name: "PurchasesGoods");
+
+ migrationBuilder.DropTable(
+ name: "Components");
+
+ migrationBuilder.DropTable(
+ name: "Builds");
+
+ migrationBuilder.DropTable(
+ name: "Goods");
+
+ migrationBuilder.DropTable(
+ name: "Purchases");
+
+ migrationBuilder.DropTable(
+ name: "Users");
+ }
+ }
+}
diff --git a/HardwareShop/HardwareShopDatabaseImplement/Migrations/HardwareShopDatabaseModelSnapshot.cs b/HardwareShop/HardwareShopDatabaseImplement/Migrations/HardwareShopDatabaseModelSnapshot.cs
new file mode 100644
index 0000000..cd31de0
--- /dev/null
+++ b/HardwareShop/HardwareShopDatabaseImplement/Migrations/HardwareShopDatabaseModelSnapshot.cs
@@ -0,0 +1,467 @@
+//
+using System;
+using HardwareShopDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace HardwareShopDatabaseImplement.Migrations
+{
+ [DbContext(typeof(HardwareShopDatabase))]
+ partial class HardwareShopDatabaseModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.4")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
+ {
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("BuildId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("ComponentId", "BuildId");
+
+ b.HasIndex("BuildId");
+
+ b.ToTable("BuildsComponents");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
+ {
+ b.Property("GoodId")
+ .HasColumnType("integer");
+
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("GoodId", "ComponentId");
+
+ b.HasIndex("ComponentId");
+
+ b.ToTable("GoodComponents");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
+ {
+ b.Property("PurchaseId")
+ .HasColumnType("integer");
+
+ b.Property("BuildId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("PurchaseId", "BuildId");
+
+ b.HasIndex("BuildId");
+
+ b.ToTable("PurchasesBuilds");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
+ {
+ b.Property("PurchaseId")
+ .HasColumnType("integer");
+
+ b.Property("GoodId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("PurchaseId", "GoodId");
+
+ b.HasIndex("GoodId");
+
+ b.ToTable("PurchasesGoods");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Cost")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("GoodName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Goods");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("DateCreate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateImplement")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("GoodId")
+ .HasColumnType("integer");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("GoodId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Login")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Role")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("BuildName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("numeric");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Builds");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("BuildId")
+ .HasColumnType("integer");
+
+ b.Property("Text")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.HasIndex("BuildId");
+
+ b.ToTable("Comments");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("DatePurchase")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("PurchaseStatus")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("numeric");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Purchases");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.BuildComponent", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
+ .WithMany("Components")
+ .HasForeignKey("BuildId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
+ .WithMany()
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Build");
+
+ b.Navigation("Component");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.GoodComponent", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Component", "Component")
+ .WithMany("GoodComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
+ .WithMany("Components")
+ .HasForeignKey("GoodId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Good");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseBuild", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
+ .WithMany("Purchases")
+ .HasForeignKey("BuildId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
+ .WithMany("Builds")
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Build");
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.ManyToMany.PurchaseGood", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
+ .WithMany()
+ .HasForeignKey("GoodId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Purchase", "Purchase")
+ .WithMany("Goods")
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Good");
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Order", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Storekeeper.Good", "Good")
+ .WithMany("Orders")
+ .HasForeignKey("GoodId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Good");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Comment", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.Worker.Build", "Build")
+ .WithMany("Comments")
+ .HasForeignKey("BuildId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Build");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
+ {
+ b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Component", b =>
+ {
+ b.Navigation("GoodComponents");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Storekeeper.Good", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Build", b =>
+ {
+ b.Navigation("Comments");
+
+ b.Navigation("Components");
+
+ b.Navigation("Purchases");
+ });
+
+ modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Worker.Purchase", b =>
+ {
+ b.Navigation("Builds");
+
+ b.Navigation("Goods");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/HardwareShop/HardwareShopView/HardwareShopView.csproj b/HardwareShop/HardwareShopView/HardwareShopView.csproj
index ab3e062..7e8c1cf 100644
--- a/HardwareShop/HardwareShopView/HardwareShopView.csproj
+++ b/HardwareShop/HardwareShopView/HardwareShopView.csproj
@@ -13,6 +13,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+