diff --git a/RenovationWork/RenovationWork/FormMain.cs b/RenovationWork/RenovationWork/FormMain.cs index 0812e2d..d4c5426 100644 --- a/RenovationWork/RenovationWork/FormMain.cs +++ b/RenovationWork/RenovationWork/FormMain.cs @@ -44,8 +44,10 @@ namespace RenovationWorkView dataGridView.DataSource = list; dataGridView.Columns["RepairId"].Visible = false; dataGridView.Columns["ImplementerId"].Visible = false; - dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } } catch (Exception ex) diff --git a/RenovationWork/RenovationWorkBusinessLogic/BusinessLogics/WorkModeling.cs b/RenovationWork/RenovationWorkBusinessLogic/BusinessLogics/WorkModeling.cs index b73fa05..6a6cf85 100644 --- a/RenovationWork/RenovationWorkBusinessLogic/BusinessLogics/WorkModeling.cs +++ b/RenovationWork/RenovationWorkBusinessLogic/BusinessLogics/WorkModeling.cs @@ -68,13 +68,14 @@ namespace RenovationWorkBusinessLogic.BusinessLogics ImplementerId = implementer.Id }); // делаем работу - Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, - 1000) * order.Count); + Thread.Sleep(implementer.WorkExperience * _rnd.Next(100,1000) * order.Count); _logger.LogDebug("DoWork. Worker {Id} finish order { Order}", implementer.Id, order.Id); _orderLogic.FinishOrder(new OrderBindingModel { Id = order.Id }); + // отдыхаем + Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } // кто-то мог уже перехватить заказ, игнорируем ошибку catch (InvalidOperationException ex) @@ -87,8 +88,6 @@ namespace RenovationWorkBusinessLogic.BusinessLogics _logger.LogError(ex, "Error while do work"); throw; } - // отдыхаем - Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100)); } }); } diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs new file mode 100644 index 0000000..387a4e5 --- /dev/null +++ b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.Designer.cs @@ -0,0 +1,257 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RenovationWorkDatabaseImplement; + +#nullable disable + +namespace RenovationWorkDatabaseImplement_.Migrations +{ + [DbContext(typeof(RenovationWorkDatabase))] + [Migration("20240501150513_addingImplementors")] + partial class addingImplementors + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.17") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.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("RenovationWorkDatabaseImplement.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("RenovationWorkDatabaseImplement.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("RenovationWorkDatabaseImplement.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("ImplementerId") + .HasColumnType("int"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("ImplementerId"); + + b.HasIndex("RepairId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("RepairName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Repairs"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("RepairId"); + + b.ToTable("RepairComponents"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Order", b => + { + b.HasOne("RenovationWorkDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RenovationWorkDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + + b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair") + .WithMany("Orders") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Implementer"); + + b.Navigation("Repair"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.RepairComponent", b => + { + b.HasOne("RenovationWorkDatabaseImplement.Component", "Component") + .WithMany("RepairComponents") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair") + .WithMany("Components") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Repair"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Component", b => + { + b.Navigation("RepairComponents"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b => + { + b.Navigation("Components"); + + b.Navigation("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.cs new file mode 100644 index 0000000..a0dfbbb --- /dev/null +++ b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/20240501150513_addingImplementors.cs @@ -0,0 +1,67 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RenovationWorkDatabaseImplement_.Migrations +{ + /// + public partial class addingImplementors : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ImplementerId", + table: "Orders", + type: "int", + nullable: true); + + migrationBuilder.CreateTable( + name: "Implementers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ImplementerFIO = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Qualification = table.Column(type: "int", nullable: false), + WorkExperience = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Implementers", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ImplementerId", + table: "Orders", + column: "ImplementerId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders", + column: "ImplementerId", + principalTable: "Implementers", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Implementers_ImplementerId", + table: "Orders"); + + migrationBuilder.DropTable( + name: "Implementers"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ImplementerId", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ImplementerId", + table: "Orders"); + } + } +} diff --git a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/RenovationWorkDatabaseModelSnapshot.cs b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/RenovationWorkDatabaseModelSnapshot.cs index f547c48..ad47729 100644 --- a/RenovationWork/RenovationWorkDatabaseImplement/Migrations/RenovationWorkDatabaseModelSnapshot.cs +++ b/RenovationWork/RenovationWorkDatabaseImplement/Migrations/RenovationWorkDatabaseModelSnapshot.cs @@ -67,6 +67,33 @@ namespace RenovationWorkDatabaseImplement_.Migrations b.ToTable("Clients"); }); + modelBuilder.Entity("RenovationWorkDatabaseImplement.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("RenovationWorkDatabaseImplement.Models.Order", b => { b.Property("Id") @@ -87,6 +114,9 @@ namespace RenovationWorkDatabaseImplement_.Migrations b.Property("DateImplement") .HasColumnType("datetime2"); + b.Property("ImplementerId") + .HasColumnType("int"); + b.Property("RepairId") .HasColumnType("int"); @@ -100,6 +130,8 @@ namespace RenovationWorkDatabaseImplement_.Migrations b.HasIndex("ClientId"); + b.HasIndex("ImplementerId"); + b.HasIndex("RepairId"); b.ToTable("Orders"); @@ -159,6 +191,10 @@ namespace RenovationWorkDatabaseImplement_.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("RenovationWorkDatabaseImplement.Models.Implementer", "Implementer") + .WithMany("Orders") + .HasForeignKey("ImplementerId"); + b.HasOne("RenovationWorkDatabaseImplement.Models.Repair", "Repair") .WithMany("Orders") .HasForeignKey("RepairId") @@ -167,6 +203,8 @@ namespace RenovationWorkDatabaseImplement_.Migrations b.Navigation("Client"); + b.Navigation("Implementer"); + b.Navigation("Repair"); }); @@ -199,6 +237,11 @@ namespace RenovationWorkDatabaseImplement_.Migrations b.Navigation("Orders"); }); + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Implementer", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("RenovationWorkDatabaseImplement.Models.Repair", b => { b.Navigation("Components"); diff --git a/RenovationWork/RenovationWorkListImplement/Implements/OrderStorage.cs b/RenovationWork/RenovationWorkListImplement/Implements/OrderStorage.cs index cd0437d..83cf16e 100644 --- a/RenovationWork/RenovationWorkListImplement/Implements/OrderStorage.cs +++ b/RenovationWork/RenovationWorkListImplement/Implements/OrderStorage.cs @@ -103,11 +103,11 @@ namespace RenovationWorkListImplement.Implements { if (model == null) return null; - var iceCream = _source.Repairs.FirstOrDefault(x => x.Id == model.Id); + var repair = _source.Repairs.FirstOrDefault(x => x.Id == model.Id); var client = _source.Clients.FirstOrDefault(x => x.Id == model.Id); var implementer = _source.Implementers.FirstOrDefault(x => x.Id == model.ImplementerId); - if (iceCream != null) - model.RepairName = iceCream.RepairName; + if (repair != null) + model.RepairName = repair.RepairName; if (client != null) model.ClientFIO = client.ClientFIO; if (implementer != null)