diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240507185552_AddMessages.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240507185552_AddMessages.cs
deleted file mode 100644
index b89caf3..0000000
--- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240507185552_AddMessages.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace BlacksmithWorkshopDatabaseImplement.Migrations
-{
- ///
- public partial class AddMessages : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- 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.CreateIndex(
- name: "IX_Messages_ClientId",
- table: "Messages",
- column: "ClientId");
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Messages");
- }
- }
-}
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240507185552_AddMessages.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240519091548_addingMessages.Designer.cs
similarity index 98%
rename from BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240507185552_AddMessages.Designer.cs
rename to BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240519091548_addingMessages.Designer.cs
index 69f7770..cac691e 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240507185552_AddMessages.Designer.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240519091548_addingMessages.Designer.cs
@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace BlacksmithWorkshopDatabaseImplement.Migrations
{
[DbContext(typeof(BlacksmithWorkshopDataBase))]
- [Migration("20240507185552_AddMessages")]
- partial class AddMessages
+ [Migration("20240519091548_addingMessages")]
+ partial class addingMessages
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -238,7 +238,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b =>
{
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
- .WithMany()
+ .WithMany("MessageInfos")
.HasForeignKey("ClientId");
b.Navigation("Client");
@@ -276,6 +276,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
{
+ b.Navigation("MessageInfos");
+
b.Navigation("Orders");
});
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240519091548_addingMessages.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240519091548_addingMessages.cs
new file mode 100644
index 0000000..2dc123b
--- /dev/null
+++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20240519091548_addingMessages.cs
@@ -0,0 +1,214 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace BlacksmithWorkshopDatabaseImplement.Migrations
+{
+ ///
+ public partial class addingMessages : Migration
+ {
+ ///
+ 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
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ComponentName = table.Column(type: "nvarchar(max)", nullable: false),
+ Cost = table.Column(type: "float", nullable: false)
+ },
+ constraints: table =>
+ {
+ 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: "Manufactures",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ManufactureName = table.Column(type: "nvarchar(max)", nullable: false),
+ Price = table.Column(type: "float", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Manufactures", 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: "ManufactureComponents",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ManufactureId = table.Column(type: "int", nullable: false),
+ ComponentId = table.Column(type: "int", nullable: false),
+ Count = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ManufactureComponents", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ManufactureComponents_Components_ComponentId",
+ column: x => x.ComponentId,
+ principalTable: "Components",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_ManufactureComponents_Manufactures_ManufactureId",
+ column: x => x.ManufactureId,
+ principalTable: "Manufactures",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Orders",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ClientId = table.Column(type: "int", nullable: false),
+ Count = table.Column(type: "int", nullable: false),
+ 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),
+ ManufactureId = table.Column(type: "int", nullable: false),
+ ImplementerId = table.Column(type: "int", nullable: true)
+ },
+ 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_Manufactures_ManufactureId",
+ column: x => x.ManufactureId,
+ principalTable: "Manufactures",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ManufactureComponents_ComponentId",
+ table: "ManufactureComponents",
+ column: "ComponentId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ManufactureComponents_ManufactureId",
+ table: "ManufactureComponents",
+ column: "ManufactureId");
+
+ 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_ManufactureId",
+ table: "Orders",
+ column: "ManufactureId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "ManufactureComponents");
+
+ migrationBuilder.DropTable(
+ name: "Messages");
+
+ migrationBuilder.DropTable(
+ name: "Orders");
+
+ migrationBuilder.DropTable(
+ name: "Components");
+
+ migrationBuilder.DropTable(
+ name: "Clients");
+
+ migrationBuilder.DropTable(
+ name: "Implementers");
+
+ migrationBuilder.DropTable(
+ name: "Manufactures");
+ }
+ }
+}
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs
index 31fe326..dd341f1 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDataBaseModelSnapshot.cs
@@ -235,7 +235,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b =>
{
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
- .WithMany()
+ .WithMany("MessageInfos")
.HasForeignKey("ClientId");
b.Navigation("Client");
@@ -273,6 +273,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
{
+ b.Navigation("MessageInfos");
+
b.Navigation("Orders");
});
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Client.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Client.cs
index 7d781f4..9ab918f 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Client.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Models/Client.cs
@@ -22,7 +22,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
public string Password { get; set; } = string.Empty;
[ForeignKey("ClientId")]
public virtual List Orders { get; set; } = new();
- public static Client? Create(ClientBindingModel model)
+ [ForeignKey("ClientId")]
+ public virtual List MessageInfos { get; set; } = new();
+ public static Client? Create(ClientBindingModel model)
{
if (model == null)
{