diff --git a/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs b/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs index 2e8f55f..347f631 100644 --- a/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/BindingModels/SupplyBindingModel.cs @@ -17,7 +17,7 @@ namespace ComputerShopContracts.BindingModels public DateTime? DateImplement { get; set; } - public Dictionary SupplyOrders + public Dictionary SupplyOrders { get; set; diff --git a/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs b/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs index e781dde..3687f9e 100644 --- a/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs +++ b/ComputerShopProvider/ComputerShopContracts/ViewModels/SupplyViewModel.cs @@ -22,7 +22,7 @@ namespace ComputerShopContracts.ViewModels [DisplayName("Номер")] public int Id { get; set; } - public Dictionary SupplyOrders + public Dictionary SupplyOrders { get; set; diff --git a/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs b/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs index 043bc5d..339413e 100644 --- a/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs +++ b/ComputerShopProvider/ComputerShopDataModels/Models/ISupplyModel.cs @@ -7,6 +7,6 @@ namespace ComputerShopDataModels.Models SupplyStatus Status { get; } DateTime DateCreate { get; } DateTime? DateImplement { get; } - Dictionary SupplyOrders { get; } + Dictionary SupplyOrders { get; } } } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230408091846_newmigration.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230408091846_newmigration.Designer.cs deleted file mode 100644 index 5431093..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230408091846_newmigration.Designer.cs +++ /dev/null @@ -1,526 +0,0 @@ -// -using System; -using ComputerShopDatabaseImplement; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - [DbContext(typeof(ComputerShopDatabase))] - [Migration("20230408091846_newmigration")] - partial class newmigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Assemblies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("ComponentId"); - - b.ToTable("AssemblyComponents"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AssemblyId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("AssemblyId"); - - b.HasIndex("OrderId"); - - b.ToTable("AssemblyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.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("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("SupplyId"); - - b.ToTable("ComponentSupplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("SupplyId"); - - b.ToTable("EquipmentReceivings"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - 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.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("ComponentId"); - - b.ToTable("Purchases"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("ReceivingId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Supplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("OrderId") - .HasColumnType("int"); - - b.Property("SupplyId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("SupplyId"); - - b.ToTable("SupplyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) - .WithMany("Assemblies") - .HasForeignKey("ClientId"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly") - .WithMany("Components") - .HasForeignKey("AssemblyId") - .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.AssemblyOrder", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly") - .WithMany("Orders") - .HasForeignKey("AssemblyId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order") - .WithMany("Assemblies") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Assembly"); - - b.Navigation("Order"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) - .WithMany("Components") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component") - .WithMany("Supplies") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply") - .WithMany("Supplies") - .HasForeignKey("SupplyId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Supply"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) - .WithMany("EquipmentReceivings") - .HasForeignKey("ClientId"); - - b.HasOne("ComputerShopDatabaseImplement.Models.Supply", null) - .WithMany("Receivings") - .HasForeignKey("SupplyId"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) - .WithMany("Orders") - .HasForeignKey("ClientId"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client") - .WithMany("Purchases") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component") - .WithMany("Purchases") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - - b.Navigation("Component"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) - .WithMany("Supplies") - .HasForeignKey("ClientId"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => - { - b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order") - .WithMany("SupplyOrders") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply") - .WithMany("Orders") - .HasForeignKey("SupplyId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Order"); - - b.Navigation("Supply"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b => - { - b.Navigation("Assemblies"); - - b.Navigation("Components"); - - b.Navigation("EquipmentReceivings"); - - b.Navigation("Orders"); - - b.Navigation("Purchases"); - - b.Navigation("Supplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b => - { - b.Navigation("AssemblyComponents"); - - b.Navigation("Purchases"); - - b.Navigation("Supplies"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => - { - b.Navigation("Assemblies"); - - b.Navigation("SupplyOrders"); - }); - - modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => - { - b.Navigation("Orders"); - - b.Navigation("Receivings"); - - b.Navigation("Supplies"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230408091846_newmigration.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230408091846_newmigration.cs deleted file mode 100644 index a626ee6..0000000 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230408091846_newmigration.cs +++ /dev/null @@ -1,399 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace ComputerShopDatabaseImplement.Migrations -{ - /// - public partial class newmigration : 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: "Assemblies", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AssemblyName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false), - ClientId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Assemblies", x => x.Id); - table.ForeignKey( - name: "FK_Assemblies_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "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), - ClientId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Components", x => x.Id); - table.ForeignKey( - name: "FK_Components_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - 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), - ClientId = 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"); - }); - - migrationBuilder.CreateTable( - name: "Supplies", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - Status = table.Column(type: "int", nullable: false), - DateCreate = table.Column(type: "datetime2", nullable: false), - DateImplement = table.Column(type: "datetime2", nullable: true), - OrderId = table.Column(type: "int", nullable: false), - ReceivingId = table.Column(type: "int", nullable: false), - ClientId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Supplies", x => x.Id); - table.ForeignKey( - name: "FK_Supplies_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "AssemblyComponents", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AssemblyId = 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_AssemblyComponents", x => x.Id); - table.ForeignKey( - name: "FK_AssemblyComponents_Assemblies_AssemblyId", - column: x => x.AssemblyId, - principalTable: "Assemblies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AssemblyComponents_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Purchases", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ComponentName = table.Column(type: "nvarchar(max)", nullable: false), - ComponentId = table.Column(type: "int", nullable: false), - 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) - }, - constraints: table => - { - table.PrimaryKey("PK_Purchases", x => x.Id); - table.ForeignKey( - name: "FK_Purchases_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - table.ForeignKey( - name: "FK_Purchases_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.NoAction); - }); - - migrationBuilder.CreateTable( - name: "AssemblyOrders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AssemblyId = table.Column(type: "int", nullable: false), - OrderId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AssemblyOrders", x => x.Id); - table.ForeignKey( - name: "FK_AssemblyOrders_Assemblies_AssemblyId", - column: x => x.AssemblyId, - principalTable: "Assemblies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AssemblyOrders_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ComponentSupplies", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - SupplyId = 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_ComponentSupplies", x => x.Id); - table.ForeignKey( - name: "FK_ComponentSupplies_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ComponentSupplies_Supplies_SupplyId", - column: x => x.SupplyId, - principalTable: "Supplies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "EquipmentReceivings", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - DateImplement = table.Column(type: "datetime2", nullable: true), - Status = table.Column(type: "int", nullable: false), - ClientId = table.Column(type: "int", nullable: true), - SupplyId = table.Column(type: "int", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_EquipmentReceivings", x => x.Id); - table.ForeignKey( - name: "FK_EquipmentReceivings_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id"); - table.ForeignKey( - name: "FK_EquipmentReceivings_Supplies_SupplyId", - column: x => x.SupplyId, - principalTable: "Supplies", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "SupplyOrders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - OrderId = table.Column(type: "int", nullable: false), - SupplyId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SupplyOrders", x => x.Id); - table.ForeignKey( - name: "FK_SupplyOrders_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_SupplyOrders_Supplies_SupplyId", - column: x => x.SupplyId, - principalTable: "Supplies", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Assemblies_ClientId", - table: "Assemblies", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyComponents_AssemblyId", - table: "AssemblyComponents", - column: "AssemblyId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyComponents_ComponentId", - table: "AssemblyComponents", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyOrders_AssemblyId", - table: "AssemblyOrders", - column: "AssemblyId"); - - migrationBuilder.CreateIndex( - name: "IX_AssemblyOrders_OrderId", - table: "AssemblyOrders", - column: "OrderId"); - - migrationBuilder.CreateIndex( - name: "IX_Components_ClientId", - table: "Components", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_ComponentSupplies_ComponentId", - table: "ComponentSupplies", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_ComponentSupplies_SupplyId", - table: "ComponentSupplies", - column: "SupplyId"); - - migrationBuilder.CreateIndex( - name: "IX_EquipmentReceivings_ClientId", - table: "EquipmentReceivings", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_EquipmentReceivings_SupplyId", - table: "EquipmentReceivings", - column: "SupplyId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ClientId", - table: "Orders", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Purchases_ClientId", - table: "Purchases", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Purchases_ComponentId", - table: "Purchases", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_Supplies_ClientId", - table: "Supplies", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_SupplyOrders_OrderId", - table: "SupplyOrders", - column: "OrderId"); - - migrationBuilder.CreateIndex( - name: "IX_SupplyOrders_SupplyId", - table: "SupplyOrders", - column: "SupplyId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AssemblyComponents"); - - migrationBuilder.DropTable( - name: "AssemblyOrders"); - - migrationBuilder.DropTable( - name: "ComponentSupplies"); - - migrationBuilder.DropTable( - name: "EquipmentReceivings"); - - migrationBuilder.DropTable( - name: "Purchases"); - - migrationBuilder.DropTable( - name: "SupplyOrders"); - - migrationBuilder.DropTable( - name: "Assemblies"); - - migrationBuilder.DropTable( - name: "Components"); - - migrationBuilder.DropTable( - name: "Orders"); - - migrationBuilder.DropTable( - name: "Supplies"); - - migrationBuilder.DropTable( - name: "Clients"); - } - } -} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs index 298295d..1693cd6 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs @@ -26,18 +26,18 @@ namespace ComputerShopDatabaseImplement.Models public int OrderId { get; set; } public int ReceivingId { get; set; } - private Dictionary? _supplyOrders = + private Dictionary? _supplyOrders = null; [NotMapped] - public Dictionary SupplyOrders + public Dictionary SupplyOrders { get { if (_supplyOrders == null) { _supplyOrders = Orders - .ToDictionary(recPC => recPC.OrderId, recPC => - (recPC.Order as IOrderModel, recPC.Count)); + .ToDictionary(recPC => recPC.SupplyId, recPC => + (recPC.OrderId, recPC.Order as IOrderModel)); } return _supplyOrders; } @@ -61,7 +61,6 @@ namespace ComputerShopDatabaseImplement.Models SupplyOrder { Order = context.Orders.First(y => y.Id == x.Key), - Count = x.Value.Item2 }).ToList() }; } @@ -94,7 +93,6 @@ namespace ComputerShopDatabaseImplement.Models // обновили количество у существующих записей foreach (var updateOrder in SupplyOrders) { - updateOrder.Count = model.SupplyOrders[updateOrder.OrderId].Item2; model.SupplyOrders.Remove(updateOrder.OrderId); } context.SaveChanges(); @@ -105,8 +103,7 @@ namespace ComputerShopDatabaseImplement.Models context.SupplyOrders.Add(new SupplyOrder { Supply = supply, - Order = context.Orders.First(x => x.Id == pc.Key), - Count = pc.Value.Item2 + Order = context.Orders.First(x => x.Id == pc.Key) }); context.SaveChanges(); }