diff --git a/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj b/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj index 26b239e..8e1c411 100644 --- a/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj +++ b/ComputerShopDatabaseImplement/ComputerShopDatabaseImplement.csproj @@ -12,6 +12,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/ComputerShopDatabaseImplement/Migrations/20240427160810_Первая пробная (Гоша).Designer.cs b/ComputerShopDatabaseImplement/Migrations/20240427160810_Первая пробная (Гоша).Designer.cs new file mode 100644 index 0000000..9c58b1e --- /dev/null +++ b/ComputerShopDatabaseImplement/Migrations/20240427160810_Первая пробная (Гоша).Designer.cs @@ -0,0 +1,452 @@ +// +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("20240427160810_Первая пробная (Гоша)")] + 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.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.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.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.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.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.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() + .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() + .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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ComputerShopDatabaseImplement/Migrations/20240427160810_Первая пробная (Гоша).cs b/ComputerShopDatabaseImplement/Migrations/20240427160810_Первая пробная (Гоша).cs new file mode 100644 index 0000000..bf28fa1 --- /dev/null +++ b/ComputerShopDatabaseImplement/Migrations/20240427160810_Первая пробная (Гоша).cs @@ -0,0 +1,338 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ComputerShopDatabaseImplement.Migrations +{ + /// + public partial class ПерваяпробнаяГоша : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Assemblies", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + AssemblyName = table.Column(type: "text", nullable: false), + Cost = table.Column(type: "double precision", nullable: false), + Category = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Assemblies", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Components", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + ComponentName = table.Column(type: "text", nullable: false), + Cost = table.Column(type: "double precision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Components", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + DateCreate = table.Column(type: "timestamp without time zone", nullable: false), + Status = table.Column(type: "integer", nullable: false), + Sum = table.Column(type: "double precision", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + ProductName = table.Column(type: "text", nullable: false), + Cost = table.Column(type: "double precision", nullable: false), + Warranty = table.Column(type: "integer", nullable: false), + ShipmentId = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Login = table.Column(type: "text", nullable: false), + Password = table.Column(type: "text", nullable: false), + Email = table.Column(type: "text", nullable: false), + Role = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AssemblyComponents", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AssemblyId = table.Column(type: "integer", nullable: false), + ComponentId = table.Column(type: "integer", nullable: false), + Count = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AssemblyComponents", x => x.Id); + table.ForeignKey( + name: "FK_AssemblyComponents_Assemblies_ComponentId", + column: x => x.ComponentId, + 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: "ProductComponents", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ProductId = table.Column(type: "integer", nullable: false), + ComponentId = table.Column(type: "integer", nullable: false), + Count = table.Column(type: "integer", nullable: false), + ComponentId1 = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductComponents", x => x.Id); + table.ForeignKey( + name: "FK_ProductComponents_Components_ComponentId1", + column: x => x.ComponentId1, + principalTable: "Components", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProductComponents_Products_ComponentId", + column: x => x.ComponentId, + principalTable: "Products", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Requests", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + AssemblyId = table.Column(type: "integer", nullable: true), + DateRequest = table.Column(type: "timestamp without time zone", nullable: false), + ClientFIO = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Requests", x => x.Id); + table.ForeignKey( + name: "FK_Requests_Assemblies_AssemblyId", + column: x => x.AssemblyId, + principalTable: "Assemblies", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Requests_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Shipments", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + UserId = table.Column(type: "integer", nullable: false), + ProviderName = table.Column(type: "text", nullable: false), + DateShipment = table.Column(type: "timestamp without time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Shipments", x => x.Id); + table.ForeignKey( + name: "FK_Shipments_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RequestOrders", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + RequestId = table.Column(type: "integer", nullable: false), + OrderId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RequestOrders", x => x.Id); + table.ForeignKey( + name: "FK_RequestOrders_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RequestOrders_Requests_RequestId", + column: x => x.RequestId, + principalTable: "Requests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ShipmentOrders", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ShipmentId = table.Column(type: "integer", nullable: false), + OrderId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShipmentOrders", x => x.Id); + table.ForeignKey( + name: "FK_ShipmentOrders_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ShipmentOrders_Shipments_ShipmentId", + column: x => x.ShipmentId, + principalTable: "Shipments", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AssemblyComponents_ComponentId", + table: "AssemblyComponents", + column: "ComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductComponents_ComponentId", + table: "ProductComponents", + column: "ComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_ProductComponents_ComponentId1", + table: "ProductComponents", + column: "ComponentId1"); + + migrationBuilder.CreateIndex( + name: "IX_RequestOrders_OrderId", + table: "RequestOrders", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_RequestOrders_RequestId", + table: "RequestOrders", + column: "RequestId"); + + migrationBuilder.CreateIndex( + name: "IX_Requests_AssemblyId", + table: "Requests", + column: "AssemblyId"); + + migrationBuilder.CreateIndex( + name: "IX_Requests_UserId", + table: "Requests", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_ShipmentOrders_OrderId", + table: "ShipmentOrders", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_ShipmentOrders_ShipmentId", + table: "ShipmentOrders", + column: "ShipmentId"); + + migrationBuilder.CreateIndex( + name: "IX_Shipments_UserId", + table: "Shipments", + column: "UserId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AssemblyComponents"); + + migrationBuilder.DropTable( + name: "ProductComponents"); + + migrationBuilder.DropTable( + name: "RequestOrders"); + + migrationBuilder.DropTable( + name: "ShipmentOrders"); + + migrationBuilder.DropTable( + name: "Components"); + + migrationBuilder.DropTable( + name: "Products"); + + migrationBuilder.DropTable( + name: "Requests"); + + migrationBuilder.DropTable( + name: "Orders"); + + migrationBuilder.DropTable( + name: "Shipments"); + + migrationBuilder.DropTable( + name: "Assemblies"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs b/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs new file mode 100644 index 0000000..1495740 --- /dev/null +++ b/ComputerShopDatabaseImplement/Migrations/ComputerShopDatabaseModelSnapshot.cs @@ -0,0 +1,449 @@ +// +using System; +using ComputerShopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#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.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.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.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.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.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.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.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() + .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() + .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"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ComputerShopRestApi/ComputerShopRestApi.csproj b/ComputerShopRestApi/ComputerShopRestApi.csproj index 249f14b..9339130 100644 --- a/ComputerShopRestApi/ComputerShopRestApi.csproj +++ b/ComputerShopRestApi/ComputerShopRestApi.csproj @@ -7,6 +7,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/ComputerShopRestApi/Program.cs b/ComputerShopRestApi/Program.cs index d0e000f..7c64ca5 100644 --- a/ComputerShopRestApi/Program.cs +++ b/ComputerShopRestApi/Program.cs @@ -1,15 +1,43 @@ +using ComputerShopBusinessLogic.BusinessLogics; +using ComputerShopContracts.BusinessLogicContracts; +using ComputerShopContracts.StorageContracts; +using ComputerShopDatabaseImplement.Implements; +using Microsoft.OpenApi.Models; + var Builder = WebApplication.CreateBuilder(args); +Builder.Logging.SetMinimumLevel(LogLevel.Trace); +Builder.Logging.AddLog4Net("log4net.config"); + + +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); + + +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); +Builder.Services.AddTransient(); + Builder.Services.AddControllers(); Builder.Services.AddEndpointsApiExplorer(); -Builder.Services.AddSwaggerGen(); +Builder.Services.AddSwaggerGen(c => +{ + c.SwaggerDoc("v1", new OpenApiInfo + { + Title = "ComputerShopRestApi", + Version = "v1" + }); +}); var App = Builder.Build(); if (App.Environment.IsDevelopment()) { App.UseSwagger(); - App.UseSwaggerUI(); + App.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "ComputerShopRestApi v1")); } App.UseHttpsRedirection(); diff --git a/ComputerShopRestApi/log4net.config b/ComputerShopRestApi/log4net.config new file mode 100644 index 0000000..59a1978 --- /dev/null +++ b/ComputerShopRestApi/log4net.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file