diff --git a/ComputerShopDatabaseImplement/Migrations/20240430103035_Внешние ключи (Гоша).Designer.cs b/ComputerShopDatabaseImplement/Migrations/20240430103035_Внешние ключи (Гоша).Designer.cs
new file mode 100644
index 0000000..cd89a6f
--- /dev/null
+++ b/ComputerShopDatabaseImplement/Migrations/20240430103035_Внешние ключи (Гоша).Designer.cs
@@ -0,0 +1,519 @@
+//
+using System;
+using ComputerShopDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace ComputerShopDatabaseImplement.Migrations
+{
+ [DbContext(typeof(ComputerShopDatabase))]
+ [Migration("20240430103035_Внешние ключи (Гоша)")]
+ partial class ВнешниеключиГоша
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.18")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("AssemblyName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Category")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Cost")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Assemblies");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("AssemblyId")
+ .HasColumnType("integer");
+
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.ToTable("AssemblyComponents");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.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("ComputerShopDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("DateCreate")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Cost")
+ .HasColumnType("double precision");
+
+ b.Property("ProductName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("ShipmentId")
+ .HasColumnType("integer");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.Property("Warranty")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ShipmentId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Products");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ProductComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("ComponentId1")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("ProductId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.HasIndex("ComponentId1");
+
+ b.ToTable("ProductComponents");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("AssemblyId")
+ .HasColumnType("integer");
+
+ b.Property("ClientFIO")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("DateRequest")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AssemblyId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Requests");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.RequestOrder", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("OrderId")
+ .HasColumnType("integer");
+
+ b.Property("RequestId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OrderId");
+
+ b.HasIndex("RequestId");
+
+ b.ToTable("RequestOrders");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("DateShipment")
+ .HasColumnType("timestamp without time zone");
+
+ b.Property("ProviderName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("UserId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Shipments");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("OrderId")
+ .HasColumnType("integer");
+
+ b.Property("ShipmentId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OrderId");
+
+ b.HasIndex("ShipmentId");
+
+ b.ToTable("ShipmentOrders");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.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("ComputerShopDatabaseImplement.Models.Assembly", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Assemblies")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
+ .WithMany("Components")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
+ .WithMany("AssemblyComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Assembly");
+
+ b.Navigation("Component");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Components")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Orders")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.Shipment", null)
+ .WithMany("Products")
+ .HasForeignKey("ShipmentId");
+
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Proucts")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ProductComponent", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.Product", "Product")
+ .WithMany("Components")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
+ .WithMany()
+ .HasForeignKey("ComponentId1")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
+ .WithMany()
+ .HasForeignKey("AssemblyId");
+
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", "User")
+ .WithMany("Requests")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Assembly");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.RequestOrder", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
+ .WithMany("Requests")
+ .HasForeignKey("OrderId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ComputerShopDatabaseImplement.Models.Request", "Request")
+ .WithMany("Orders")
+ .HasForeignKey("RequestId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Order");
+
+ b.Navigation("Request");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", "User")
+ .WithMany("Shipments")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ShipmentOrder", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
+ .WithMany("Shipments")
+ .HasForeignKey("OrderId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("ComputerShopDatabaseImplement.Models.Shipment", "Shipment")
+ .WithMany("Orders")
+ .HasForeignKey("ShipmentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Order");
+
+ b.Navigation("Shipment");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
+ {
+ b.Navigation("Components");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
+ {
+ b.Navigation("AssemblyComponents");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
+ {
+ b.Navigation("Requests");
+
+ b.Navigation("Shipments");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
+ {
+ b.Navigation("Components");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Request", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
+ {
+ b.Navigation("Orders");
+
+ b.Navigation("Products");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.User", b =>
+ {
+ b.Navigation("Assemblies");
+
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+
+ b.Navigation("Proucts");
+
+ b.Navigation("Requests");
+
+ b.Navigation("Shipments");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/ComputerShopDatabaseImplement/Migrations/20240430103035_Внешние ключи (Гоша).cs b/ComputerShopDatabaseImplement/Migrations/20240430103035_Внешние ключи (Гоша).cs
new file mode 100644
index 0000000..eb61aae
--- /dev/null
+++ b/ComputerShopDatabaseImplement/Migrations/20240430103035_Внешние ключи (Гоша).cs
@@ -0,0 +1,122 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace ComputerShopDatabaseImplement.Migrations
+{
+ ///
+ public partial class ВнешниеключиГоша : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateIndex(
+ name: "IX_Products_ShipmentId",
+ table: "Products",
+ column: "ShipmentId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Products_UserId",
+ table: "Products",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Orders_UserId",
+ table: "Orders",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Components_UserId",
+ table: "Components",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Assemblies_UserId",
+ table: "Assemblies",
+ column: "UserId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Assemblies_Users_UserId",
+ table: "Assemblies",
+ column: "UserId",
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Components_Users_UserId",
+ table: "Components",
+ column: "UserId",
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Orders_Users_UserId",
+ table: "Orders",
+ column: "UserId",
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Products_Shipments_ShipmentId",
+ table: "Products",
+ column: "ShipmentId",
+ principalTable: "Shipments",
+ principalColumn: "Id");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Products_Users_UserId",
+ table: "Products",
+ column: "UserId",
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Assemblies_Users_UserId",
+ table: "Assemblies");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Components_Users_UserId",
+ table: "Components");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Orders_Users_UserId",
+ table: "Orders");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Products_Shipments_ShipmentId",
+ table: "Products");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Products_Users_UserId",
+ table: "Products");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Products_ShipmentId",
+ table: "Products");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Products_UserId",
+ table: "Products");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Orders_UserId",
+ table: "Orders");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Components_UserId",
+ table: "Components");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Assemblies_UserId",
+ table: "Assemblies");
+ }
+ }
+}
diff --git a/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs b/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs
index 1495740..009af65 100644
--- a/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs
+++ b/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs
@@ -46,6 +46,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
+ b.HasIndex("UserId");
+
b.ToTable("Assemblies");
});
@@ -93,6 +95,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
+ b.HasIndex("UserId");
+
b.ToTable("Components");
});
@@ -118,6 +122,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
+ b.HasIndex("UserId");
+
b.ToTable("Orders");
});
@@ -147,6 +153,10 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
+ b.HasIndex("ShipmentId");
+
+ b.HasIndex("UserId");
+
b.ToTable("Products");
});
@@ -308,6 +318,15 @@ namespace ComputerShopDatabaseImplement.Migrations
b.ToTable("Users");
});
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Assemblies")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
@@ -327,6 +346,37 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Navigation("Component");
});
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Components")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Orders")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Product", b =>
+ {
+ b.HasOne("ComputerShopDatabaseImplement.Models.Shipment", null)
+ .WithMany("Products")
+ .HasForeignKey("ShipmentId");
+
+ b.HasOne("ComputerShopDatabaseImplement.Models.User", null)
+ .WithMany("Proucts")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ProductComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Product", "Product")
@@ -353,7 +403,7 @@ namespace ComputerShopDatabaseImplement.Migrations
.HasForeignKey("AssemblyId");
b.HasOne("ComputerShopDatabaseImplement.Models.User", "User")
- .WithMany()
+ .WithMany("Requests")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -385,7 +435,7 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.User", "User")
- .WithMany()
+ .WithMany("Shipments")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -442,6 +492,23 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Shipment", b =>
{
b.Navigation("Orders");
+
+ b.Navigation("Products");
+ });
+
+ modelBuilder.Entity("ComputerShopDatabaseImplement.Models.User", b =>
+ {
+ b.Navigation("Assemblies");
+
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+
+ b.Navigation("Proucts");
+
+ b.Navigation("Requests");
+
+ b.Navigation("Shipments");
});
#pragma warning restore 612, 618
}
diff --git a/ComputerShopDatabaseImplement/Models/Shipment.cs b/ComputerShopDatabaseImplement/Models/Shipment.cs
index c0cbb92..744b9a2 100644
--- a/ComputerShopDatabaseImplement/Models/Shipment.cs
+++ b/ComputerShopDatabaseImplement/Models/Shipment.cs
@@ -48,6 +48,9 @@ namespace ComputerShopDatabaseImplement.Models
[ForeignKey("ShipmentId")]
public virtual List Orders { get; set; } = new();
+ [ForeignKey("ShipmentId")]
+ public virtual List Products { get; set; } = new();
+
//!!!ПРОВЕРИТЬ, ЧТО ПРАВИЛЬНО ПРИСВАИВАЮ ЗНАЧЕНИЕ СПИСКУ ЗАКАЗОВ
public static Shipment Create(ComputerShopDatabase context, ShipmentBindingModel model)
diff --git a/ComputerShopDatabaseImplement/Models/User.cs b/ComputerShopDatabaseImplement/Models/User.cs
index 69f2b2e..db78684 100644
--- a/ComputerShopDatabaseImplement/Models/User.cs
+++ b/ComputerShopDatabaseImplement/Models/User.cs
@@ -5,6 +5,7 @@ using ComputerShopDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -27,6 +28,22 @@ namespace ComputerShopDatabaseImplement.Models
[Required]
public UserRole Role { get; set; }
+ [ForeignKey("UserId")]
+ public virtual List Shipments { get; set; } = new();
+ [ForeignKey("UserId")]
+ public virtual List Orders { get; set; } = new();
+ [ForeignKey("UserId")]
+ public virtual List Requests { get; set; } = new();
+
+ [ForeignKey("UserId")]
+ public virtual List Assemblies { get; set; } = new();
+ [ForeignKey("UserId")]
+ public virtual List Components { get; set; } = new();
+
+ [ForeignKey("UserId")]
+ public virtual List Proucts { get; set; } = new();
+
+
public static User Create(UserBindingModel model)
{
return new User