From 4423570f6ab2a4061bb030e439c091e538a2053a Mon Sep 17 00:00:00 2001 From: aleksandr chegodaev Date: Sun, 16 Jun 2024 21:27:41 +0400 Subject: [PATCH] lab6 ispr --- .../Implements/OrderStorage.cs | 13 -- .../20240616171737_InitialCreate.Designer.cs | 214 ------------------ .../20240616171737_InitialCreate.cs | 155 ------------- ... 20240616172608_InitialCreate.Designer.cs} | 2 +- ...ate.cs => 20240616172608_InitialCreate.cs} | 0 .../LawFirmDatabaseModelSnapshot.cs | 43 ++++ .../Implements/OrderStorage.cs | 20 -- 7 files changed, 44 insertions(+), 403 deletions(-) delete mode 100644 LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.Designer.cs delete mode 100644 LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.cs rename LawFirm/LawFirmDatabaseImplement/Migrations/{20240510203333_InitialCreate.Designer.cs => 20240616172608_InitialCreate.Designer.cs} (99%) rename LawFirm/LawFirmDatabaseImplement/Migrations/{20240510203333_InitialCreate.cs => 20240616172608_InitialCreate.cs} (100%) diff --git a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs index 222251a..f117a60 100644 --- a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs @@ -16,19 +16,6 @@ namespace LawFirmDatabaseImplement.Implements { public OrderViewModel? GetElement(OrderSearchModel model) { - /*if (!model.Id.HasValue) - { - return null; - } - using var context = new LawFirmDatabase(); - return context.Orders - .Include(x => x.Document) - .Include(x => x.Client) - .Include(x => x.Implementer) - .FirstOrDefault(x => - (model.Status == null || model.Status != null && model.Status.Contains(x.Status)) && - model.ImplementerId.HasValue && x.ImplementerId == model.ImplementerId || - model.Id.HasValue && x.Id == model.Id)?.GetViewModel;*/ if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue)) { return null; diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.Designer.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.Designer.cs deleted file mode 100644 index 220940f..0000000 --- a/LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.Designer.cs +++ /dev/null @@ -1,214 +0,0 @@ -// -using System; -using LawFirmDatabaseImplement; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace LawFirmDatabaseImplement.Migrations -{ - [DbContext(typeof(LawFirmDatabase))] - [Migration("20240616171737_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("LawFirmDatabaseImplement.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("LawFirmDatabaseImplement.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("LawFirmDatabaseImplement.Models.Document", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("DocumentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Documents"); - }); - - modelBuilder.Entity("LawFirmDatabaseImplement.Models.DocumentComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DocumentId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("DocumentId"); - - b.ToTable("DocumentComponents"); - }); - - modelBuilder.Entity("LawFirmDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("DocumentId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("DocumentId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("LawFirmDatabaseImplement.Models.DocumentComponent", b => - { - b.HasOne("LawFirmDatabaseImplement.Models.Component", "Component") - .WithMany("DocumentComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document") - .WithMany("Components") - .HasForeignKey("DocumentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Document"); - }); - - modelBuilder.Entity("LawFirmDatabaseImplement.Models.Order", b => - { - b.HasOne("LawFirmDatabaseImplement.Models.Client", "Client") - .WithMany("Orders") - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document") - .WithMany("Orders") - .HasForeignKey("DocumentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Client"); - - b.Navigation("Document"); - }); - - modelBuilder.Entity("LawFirmDatabaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - - modelBuilder.Entity("LawFirmDatabaseImplement.Models.Component", b => - { - b.Navigation("DocumentComponents"); - }); - - modelBuilder.Entity("LawFirmDatabaseImplement.Models.Document", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.cs deleted file mode 100644 index 14566b7..0000000 --- a/LawFirm/LawFirmDatabaseImplement/Migrations/20240616171737_InitialCreate.cs +++ /dev/null @@ -1,155 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace LawFirmDatabaseImplement.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Clients", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Clients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Components", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ComponentName = table.Column(type: "nvarchar(max)", nullable: false), - Cost = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Components", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Documents", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - DocumentName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Documents", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "DocumentComponents", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - DocumentId = 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_DocumentComponents", x => x.Id); - table.ForeignKey( - name: "FK_DocumentComponents_Components_ComponentId", - column: x => x.ComponentId, - principalTable: "Components", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_DocumentComponents_Documents_DocumentId", - column: x => x.DocumentId, - principalTable: "Documents", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - DocumentId = 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_Orders", x => x.Id); - table.ForeignKey( - name: "FK_Orders_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_Orders_Documents_DocumentId", - column: x => x.DocumentId, - principalTable: "Documents", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_DocumentComponents_ComponentId", - table: "DocumentComponents", - column: "ComponentId"); - - migrationBuilder.CreateIndex( - name: "IX_DocumentComponents_DocumentId", - table: "DocumentComponents", - column: "DocumentId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ClientId", - table: "Orders", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_DocumentId", - table: "Orders", - column: "DocumentId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DocumentComponents"); - - migrationBuilder.DropTable( - name: "Orders"); - - migrationBuilder.DropTable( - name: "Components"); - - migrationBuilder.DropTable( - name: "Clients"); - - migrationBuilder.DropTable( - name: "Documents"); - } - } -} diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/20240510203333_InitialCreate.Designer.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/20240616172608_InitialCreate.Designer.cs similarity index 99% rename from LawFirm/LawFirmDatabaseImplement/Migrations/20240510203333_InitialCreate.Designer.cs rename to LawFirm/LawFirmDatabaseImplement/Migrations/20240616172608_InitialCreate.Designer.cs index 0e3e880..062f4ba 100644 --- a/LawFirm/LawFirmDatabaseImplement/Migrations/20240510203333_InitialCreate.Designer.cs +++ b/LawFirm/LawFirmDatabaseImplement/Migrations/20240616172608_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace LawFirmDatabaseImplement.Migrations { [DbContext(typeof(LawFirmDatabase))] - [Migration("20240510203333_InitialCreate")] + [Migration("20240616172608_InitialCreate")] partial class InitialCreate { /// diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/20240510203333_InitialCreate.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/20240616172608_InitialCreate.cs similarity index 100% rename from LawFirm/LawFirmDatabaseImplement/Migrations/20240510203333_InitialCreate.cs rename to LawFirm/LawFirmDatabaseImplement/Migrations/20240616172608_InitialCreate.cs diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs index 3b38b30..76a60ba 100644 --- a/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs +++ b/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs @@ -113,6 +113,33 @@ namespace LawFirmDatabaseImplement.Migrations b.ToTable("DocumentComponents"); }); + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Implementer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ImplementerFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("WorkExperience") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("Implementers"); + }); + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -136,6 +163,9 @@ namespace LawFirmDatabaseImplement.Migrations b.Property("DocumentId") .HasColumnType("int"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("Status") .HasColumnType("int"); @@ -148,6 +178,8 @@ namespace LawFirmDatabaseImplement.Migrations b.HasIndex("DocumentId"); + b.HasIndex("ImplementerId"); + b.ToTable("Orders"); }); @@ -184,9 +216,15 @@ namespace LawFirmDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("LawFirmDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.Navigation("Client"); b.Navigation("Document"); + + b.Navigation("Implementer"); }); modelBuilder.Entity("LawFirmDatabaseImplement.Models.Client", b => @@ -205,6 +243,11 @@ namespace LawFirmDatabaseImplement.Migrations b.Navigation("Orders"); }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); #pragma warning restore 612, 618 } } diff --git a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs index 04cec49..1097b37 100644 --- a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs @@ -75,26 +75,6 @@ namespace LawFirmListImplement.Implements } public OrderViewModel? GetElement(OrderSearchModel model) { - /*if (!model.Id.HasValue) - { - return null; - } - foreach (var order in _source.Orders) - { - if (model.Id.HasValue && order.Id == model.Id) - { - return order.GetViewModel; - } - else if (model.ImplementerId.HasValue && model.Status != null && order.ImplementerId == model.ImplementerId && model.Status.Contains(order.Status)) - { - return GetViewModel(order); - } - else if (model.ImplementerId.HasValue && model.ImplementerId == order.ImplementerId) - { - return GetViewModel(order); - } - } - return null;*/ if (!model.Id.HasValue) { return null;