diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs index f416254..62462a4 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/ComputerShopDatabase.cs @@ -15,7 +15,7 @@ namespace ComputerShopDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseCW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } @@ -27,5 +27,7 @@ namespace ComputerShopDatabaseImplement public virtual DbSet Supplies { set; get; } public virtual DbSet SupplyOrders { set; get; } public virtual DbSet EquipmentReceivings { set; get; } + public virtual DbSet ComponentSupplies { set; get; } + public virtual DbSet AssemblyOrders { set; get; } } } diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/AssemblyStorage.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/AssemblyStorage.cs index 5bf0647..3ddd7a4 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/AssemblyStorage.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/AssemblyStorage.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; namespace ComputerShopDatabaseImplement.Implements { - internal class AssemblyStorage : IAssemblyStorage + public class AssemblyStorage : IAssemblyStorage { public List GetFullList() { diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/ComponentStorage.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/ComponentStorage.cs index df8d57d..13aac14 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/ComponentStorage.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/ComponentStorage.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace ComputerShopDatabaseImplement.Implements { - internal class ComponentStorage : IComponentStorage + public class ComponentStorage : IComponentStorage { public List GetFullList() { diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/PurchaseStorage.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/PurchaseStorage.cs index 4846077..aa47f9a 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/PurchaseStorage.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Implements/PurchaseStorage.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace ComputerShopDatabaseImplement.Implements { - internal class PurchaseStorage : IPurchaseStorage + public class PurchaseStorage : IPurchaseStorage { public PurchaseViewModel? GetElement(PurchaseSearchModel model) { diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230407125028_testmig.Designer.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230407125028_testmig.Designer.cs new file mode 100644 index 0000000..1af2055 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230407125028_testmig.Designer.cs @@ -0,0 +1,414 @@ +// +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("20230407125028_testmig")] + partial class testmig + { + /// + 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("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + 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.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("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("DateImplement") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SupplyId") + .HasColumnType("int"); + + b.HasKey("Id"); + + 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("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + 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("ComponentId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + 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.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.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.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.Supply", null) + .WithMany("Receivings") + .HasForeignKey("SupplyId"); + }); + + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => + { + b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component") + .WithMany("Purchases") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + }); + + 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.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/20230407125028_testmig.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230407125028_testmig.cs new file mode 100644 index 0000000..eef6ac7 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20230407125028_testmig.cs @@ -0,0 +1,313 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ComputerShopDatabaseImplement.Migrations +{ + /// + public partial class testmig : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + 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) + }, + constraints: table => + { + table.PrimaryKey("PK_Assemblies", 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: "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) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.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) + }, + constraints: table => + { + table.PrimaryKey("PK_Supplies", x => x.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), + 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_Components_ComponentId", + column: x => x.ComponentId, + principalTable: "Components", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + 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), + SupplyId = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_EquipmentReceivings", x => x.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_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_ComponentSupplies_ComponentId", + table: "ComponentSupplies", + column: "ComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_ComponentSupplies_SupplyId", + table: "ComponentSupplies", + column: "SupplyId"); + + migrationBuilder.CreateIndex( + name: "IX_EquipmentReceivings_SupplyId", + table: "EquipmentReceivings", + column: "SupplyId"); + + migrationBuilder.CreateIndex( + name: "IX_Purchases_ComponentId", + table: "Purchases", + column: "ComponentId"); + + 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"); + } + } +} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs new file mode 100644 index 0000000..5328692 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs @@ -0,0 +1,411 @@ +// +using System; +using ComputerShopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace ComputerShopDatabaseImplement.Migrations +{ + [DbContext(typeof(ComputerShopDatabase))] + partial class ComputerShopDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(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("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + 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.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("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("DateImplement") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SupplyId") + .HasColumnType("int"); + + b.HasKey("Id"); + + 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("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + 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("ComponentId"); + + b.ToTable("Purchases"); + }); + + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + 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.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.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.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.Supply", null) + .WithMany("Receivings") + .HasForeignKey("SupplyId"); + }); + + modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => + { + b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component") + .WithMany("Purchases") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + }); + + 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.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/Models/Assembly.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Assembly.cs index a61628a..eebe45f 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Assembly.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Assembly.cs @@ -38,7 +38,7 @@ namespace ComputerShopDatabaseImplement.Models [ForeignKey("AssemblyId")] public virtual List Components { get; set; } = new(); [ForeignKey("AssemblyId")] - public virtual List Purchases { get; set; } = new(); + public virtual List Orders { get; set; } = new(); public static Assembly Create(ComputerShopDatabase context, AssemblyBindingModel model) { return new Assembly() diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/AssemblyOrder.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/AssemblyOrder.cs new file mode 100644 index 0000000..d084da4 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/AssemblyOrder.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDatabaseImplement.Models +{ + internal class AssemblyOrder + { + public int Id { get; set; } + [Required] + public int AssemblyId { get; set; } + [Required] + public int OrderId { get; set; } + [Required] + public int Count { get; set; } + public virtual Order Order { get; set; } = new(); + public virtual Assembly Assembly { get; set; } = new(); + } +} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Component.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Component.cs index f0b8cde..9f52926 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Component.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Component.cs @@ -21,6 +21,10 @@ namespace ComputerShopDatabaseImplement.Models [ForeignKey("ComponentId")] public virtual List AssemblyComponents { get; set; } = new(); + [ForeignKey("ComponentId")] + public virtual List Purchases { get; set; } = new(); + [ForeignKey("ComponentId")] + public virtual List Supplies { get; set; } = new(); public static Component? Create(ComponentBindingModel model) { if (model == null) diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/ComponentSupply.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/ComponentSupply.cs new file mode 100644 index 0000000..2772ef6 --- /dev/null +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/ComponentSupply.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopDatabaseImplement.Models +{ + internal class ComponentSupply + { + public int Id { get; set; } + [Required] + public int SupplyId { get; set; } + [Required] + public int ComponentId { get; set; } + [Required] + public int Count { get; set; } + public virtual Supply Supply { get; set; } = new(); + public virtual Component Component { get; set; } = new(); + } +} diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs index 3ea9129..c0f96fd 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Order.cs @@ -24,8 +24,9 @@ namespace ComputerShopDatabaseImplement.Models public DateTime? DateImplement { get; private set; } [ForeignKey("OrderId")] - public virtual List SupplyOrders { get; set; } = - new(); + public virtual List SupplyOrders { get; set; } = new(); + [ForeignKey("OrderId")] + public virtual List Assemblies { get; set; } = new(); public static Order? Create(OrderBindingModel model) { if (model == null) diff --git a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs index a15d047..298295d 100644 --- a/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs +++ b/ComputerShopProvider/ComputerShopDatabaseImplement/Models/Supply.cs @@ -46,7 +46,9 @@ namespace ComputerShopDatabaseImplement.Models public virtual List Orders { get; set; } = new(); [ForeignKey("SupplyId")] public virtual List Receivings { get; set; } = new(); - + [ForeignKey("SupplyId")] + public virtual List Supplies { get; set; } = new(); + public static Supply Create(ComputerShopDatabase context, SupplyBindingModel model) { return new Supply diff --git a/ComputerShopProvider/ComputerShopView/ComputerShopView.csproj b/ComputerShopProvider/ComputerShopView/ComputerShopView.csproj index 16fbc32..5b84151 100644 --- a/ComputerShopProvider/ComputerShopView/ComputerShopView.csproj +++ b/ComputerShopProvider/ComputerShopView/ComputerShopView.csproj @@ -19,4 +19,11 @@ + + + + + + + \ No newline at end of file diff --git a/ComputerShopProvider/ComputerShopView/Program.cs b/ComputerShopProvider/ComputerShopView/Program.cs index ce62421..266e790 100644 --- a/ComputerShopProvider/ComputerShopView/Program.cs +++ b/ComputerShopProvider/ComputerShopView/Program.cs @@ -1,9 +1,19 @@ +using ComputerShopBusinessLogic.BusinessLogics; +using ComputerShopContracts.BusinessLogicContracts; +using ComputerShopContracts.StorageContracts; +using ComputerShopDatabaseImplement.Implements; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; + namespace ComputerShopView { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// - /// The main entry point for the application. + /// The main entry point for the application. /// [STAThread] static void Main() @@ -11,7 +21,25 @@ namespace ComputerShopView // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file