From 1cda9ec164eaa09ce72d39d408bcc96cd4ce01fd Mon Sep 17 00:00:00 2001 From: Allllen4a Date: Fri, 31 May 2024 23:21:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AF=20=D0=B2=D1=81=D0=B5=D0=B3=D0=B4=D0=B0?= =?UTF-8?q?=20=D1=82=D0=B2=D0=B5=D1=80=D0=B4=D0=B8=D0=BB,=20=D1=87=D1=82?= =?UTF-8?q?=D0=BE=20=D1=81=D1=83=D0=B4=D1=8C=D0=B1=D0=B0=20=E2=80=94=20?= =?UTF-8?q?=D0=B8=D0=B3=D1=80=D0=B0.=20=D0=A7=D1=82=D0=BE=20=D0=B7=D0=B0?= =?UTF-8?q?=D1=87=D0=B5=D0=BC=20=D0=BD=D0=B0=D0=BC=20=D1=80=D1=8B=D0=B1?= =?UTF-8?q?=D0=B0,=20=D1=80=D0=B0=D0=B7=20=D0=B5=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?=D0=B8=D0=BA=D1=80=D0=B0.=20=D0=A7=D1=82=D0=BE=20=D0=B3=D0=BE?= =?UTF-8?q?=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B9=20=D1=81=D1=82?= =?UTF-8?q?=D0=B8=D0=BB=D1=8C=20=D0=BF=D0=BE=D0=B1=D0=B5=D0=B4=D0=B8=D1=82?= =?UTF-8?q?,=20=D0=BA=D0=B0=D0=BA=20=D1=88=D0=BA=D0=BE=D0=BB=D0=B0,=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BA=20=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D1=82=D0=BE=D1=80=D1=87=D0=B0=D1=82?= =?UTF-8?q?=D1=8C,=20=D0=B8=D0=B7=D0=B1=D0=B5=D0=B6=D0=B0=D0=B2=20=D1=83?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B0.=20=D0=AF=20=D1=81=D0=B8=D0=B6=D1=83?= =?UTF-8?q?=20=D1=83=20=D0=BE=D0=BA=D0=BD=D0=B0.=20=D0=97=D0=B0=20=D0=BE?= =?UTF-8?q?=D0=BA=D0=BD=D0=BE=D0=BC=20=D0=BE=D1=81=D0=B8=D0=BD=D0=B0.=20?= =?UTF-8?q?=D0=AF=20=D0=BB=D1=8E=D0=B1=D0=B8=D0=BB=20=D0=BD=D0=B5=D0=BC?= =?UTF-8?q?=D0=BD=D0=BE=D0=B3=D0=B8=D1=85.=20=D0=9E=D0=B4=D0=BD=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=20=E2=80=94=20=D1=81=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeautySalonDatabase.cs | 7 + .../20240531181713_HZmigration.Designer.cs | 741 ++++++++++++++++++ .../Migrations/20240531181713_HZmigration.cs | 112 +++ .../BeautySalonDatabaseModelSnapshot.cs | 74 +- .../Controllers/ProcedureController.cs | 25 +- 5 files changed, 941 insertions(+), 18 deletions(-) create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.Designer.cs create mode 100644 BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.cs diff --git a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs index 73db706..87da54c 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/BeautySalonDatabase.cs @@ -22,6 +22,13 @@ namespace BeautySalonDatabaseImplement base.OnConfiguring(optionsBuilder); } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasOne(e => e.Procedure) + .WithOne(p => p.Evaluation) + .HasForeignKey(p => p.EvaluationId); + } public virtual DbSet Orders { set; get; } public virtual DbSet LaborCosts { set; get; } diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.Designer.cs b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.Designer.cs new file mode 100644 index 0000000..d2be27e --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.Designer.cs @@ -0,0 +1,741 @@ +// +using System; +using BeautySalonDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BeautySalonDatabaseImplement.Migrations +{ + [DbContext(typeof(BeautySalonDatabase))] + [Migration("20240531181713_HZmigration")] + partial class HZmigration + { + /// + 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("BeautySalonDatabaseImplement.Models.Cosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Brand") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CosmeticName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CosmeticPrice") + .HasColumnType("float"); + + b.Property("LaborCostId") + .HasColumnType("int"); + + b.Property("StorekeeperId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LaborCostId"); + + b.HasIndex("StorekeeperId"); + + b.ToTable("Cosmetics"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.CosmeticProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("CosmeticProcedures"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Evaluation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PointsCosmetics") + .HasColumnType("float"); + + b.Property("PointsProcedure") + .HasColumnType("float"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.Property("WorkerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("WorkerId"); + + b.ToTable("Evaluations"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.LaborCosts", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Difficulty") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NumberHours") + .HasColumnType("int"); + + b.Property("StorekeeperId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("StorekeeperId"); + + b.ToTable("LaborCosts"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MessageInfo", b => + { + b.Property("MessageId") + .HasColumnType("nvarchar(450)"); + + b.Property("Body") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateDelivery") + .HasColumnType("datetime2"); + + b.Property("SenderName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StorekeeperId") + .HasColumnType("int"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("WorkerId") + .HasColumnType("int"); + + b.HasKey("MessageId"); + + b.HasIndex("StorekeeperId"); + + b.HasIndex("WorkerId"); + + b.ToTable("MessageInfos"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("int"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("OrderId"); + + b.ToTable("OrderCosmetics"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("OrderProcedureCount") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("OrderProcedures"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("OrderServiceCount") + .HasColumnType("int"); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ServiceId"); + + b.ToTable("OrderServices"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.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("OrderAmount") + .HasColumnType("float"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("WorkerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("WorkerId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EvaluationId") + .HasColumnType("int"); + + b.Property("ProcedureDuration") + .HasColumnType("float"); + + b.Property("ProcedureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProcedurePrice") + .HasColumnType("float"); + + b.Property("WorkerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EvaluationId") + .IsUnique(); + + b.HasIndex("WorkerId"); + + b.ToTable("Procedures"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("ProcedureCosmetics"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ServiceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ServicePrice") + .HasColumnType("float"); + + b.Property("StorekeeperId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("StorekeeperId"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceCosmetics"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.Property("ServiceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ProcedureId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceProcedures"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Storekeeper", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Storekeepers"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Worker", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("FullName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Workers"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.LaborCosts", "LaborCost") + .WithMany("Cosmetics") + .HasForeignKey("LaborCostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Storekeeper", "Storekeeper") + .WithMany() + .HasForeignKey("StorekeeperId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LaborCost"); + + b.Navigation("Storekeeper"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.CosmeticProcedure", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic") + .WithMany("Procedures") + .HasForeignKey("CosmeticId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") + .WithMany("Cosmetics") + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Evaluation", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Worker", "Worker") + .WithMany() + .HasForeignKey("WorkerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.LaborCosts", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Storekeeper", "Storekeeper") + .WithMany() + .HasForeignKey("StorekeeperId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Storekeeper"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MessageInfo", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Storekeeper", "Storekeeper") + .WithMany() + .HasForeignKey("StorekeeperId"); + + b.HasOne("BeautySalonDatabaseImplement.Models.Worker", "Worker") + .WithMany() + .HasForeignKey("WorkerId"); + + b.Navigation("Storekeeper"); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderCosmetic", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic") + .WithMany() + .HasForeignKey("CosmeticId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Order_", "Order") + .WithMany("Cosmetics") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderProcedure", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Order_", "Order") + .WithMany("Procedures") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderService", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Order_", "Order") + .WithMany("Services") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service") + .WithMany() + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Order_", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Worker", "Worker") + .WithMany() + .HasForeignKey("WorkerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Evaluation", "Evaluation") + .WithOne("Procedure") + .HasForeignKey("BeautySalonDatabaseImplement.Models.Procedure", "EvaluationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Worker", "Worker") + .WithMany() + .HasForeignKey("WorkerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Evaluation"); + + b.Navigation("Worker"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureCosmetic", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic") + .WithMany() + .HasForeignKey("CosmeticId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Storekeeper", "Storekeeper") + .WithMany() + .HasForeignKey("StorekeeperId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Storekeeper"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceCosmetic", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic") + .WithMany() + .HasForeignKey("CosmeticId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service") + .WithMany("Cosmetics") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceProcedure", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Service", "Service") + .WithMany("Procedures") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Procedure"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b => + { + b.Navigation("Procedures"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Evaluation", b => + { + b.Navigation("Procedure"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.LaborCosts", b => + { + b.Navigation("Cosmetics"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Order_", b => + { + b.Navigation("Cosmetics"); + + b.Navigation("Procedures"); + + b.Navigation("Services"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b => + { + b.Navigation("Cosmetics"); + }); + + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b => + { + b.Navigation("Cosmetics"); + + b.Navigation("Procedures"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.cs b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.cs new file mode 100644 index 0000000..a0a2010 --- /dev/null +++ b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240531181713_HZmigration.cs @@ -0,0 +1,112 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BeautySalonDatabaseImplement.Migrations +{ + /// + public partial class HZmigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Evaluations_Procedures_ProcedureId", + table: "Evaluations"); + + migrationBuilder.DropIndex( + name: "IX_Evaluations_ProcedureId", + table: "Evaluations"); + + migrationBuilder.AddColumn( + name: "EvaluationId", + table: "Procedures", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "ProcedureCosmetics", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CosmeticId = table.Column(type: "int", nullable: false), + ProcedureId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProcedureCosmetics", x => x.Id); + table.ForeignKey( + name: "FK_ProcedureCosmetics_Cosmetics_CosmeticId", + column: x => x.CosmeticId, + principalTable: "Cosmetics", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ProcedureCosmetics_Procedures_ProcedureId", + column: x => x.ProcedureId, + principalTable: "Procedures", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Procedures_EvaluationId", + table: "Procedures", + column: "EvaluationId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ProcedureCosmetics_CosmeticId", + table: "ProcedureCosmetics", + column: "CosmeticId"); + + migrationBuilder.CreateIndex( + name: "IX_ProcedureCosmetics_ProcedureId", + table: "ProcedureCosmetics", + column: "ProcedureId"); + + migrationBuilder.AddForeignKey( + name: "FK_Procedures_Evaluations_EvaluationId", + table: "Procedures", + column: "EvaluationId", + principalTable: "Evaluations", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Procedures_Evaluations_EvaluationId", + table: "Procedures"); + + migrationBuilder.DropTable( + name: "ProcedureCosmetics"); + + migrationBuilder.DropIndex( + name: "IX_Procedures_EvaluationId", + table: "Procedures"); + + migrationBuilder.DropColumn( + name: "EvaluationId", + table: "Procedures"); + + migrationBuilder.CreateIndex( + name: "IX_Evaluations_ProcedureId", + table: "Evaluations", + column: "ProcedureId"); + + migrationBuilder.AddForeignKey( + name: "FK_Evaluations_Procedures_ProcedureId", + table: "Evaluations", + column: "ProcedureId", + principalTable: "Procedures", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs index 0d96e40..2ed55ed 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs @@ -104,8 +104,6 @@ namespace BeautySalonDatabaseImplement.Migrations b.HasKey("Id"); - b.HasIndex("ProcedureId"); - b.HasIndex("WorkerId"); b.ToTable("Evaluations"); @@ -284,6 +282,9 @@ namespace BeautySalonDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("EvaluationId") + .HasColumnType("int"); + b.Property("ProcedureDuration") .HasColumnType("float"); @@ -299,11 +300,40 @@ namespace BeautySalonDatabaseImplement.Migrations b.HasKey("Id"); + b.HasIndex("EvaluationId") + .IsUnique(); + b.HasIndex("WorkerId"); b.ToTable("Procedures"); }); + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("ProcedureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("ProcedureCosmetics"); + }); + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b => { b.Property("Id") @@ -477,20 +507,12 @@ namespace BeautySalonDatabaseImplement.Migrations modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Evaluation", b => { - b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") - .WithMany() - .HasForeignKey("ProcedureId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - b.HasOne("BeautySalonDatabaseImplement.Models.Worker", "Worker") .WithMany() .HasForeignKey("WorkerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Procedure"); - b.Navigation("Worker"); }); @@ -590,15 +612,42 @@ namespace BeautySalonDatabaseImplement.Migrations modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b => { + b.HasOne("BeautySalonDatabaseImplement.Models.Evaluation", "Evaluation") + .WithOne("Procedure") + .HasForeignKey("BeautySalonDatabaseImplement.Models.Procedure", "EvaluationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("BeautySalonDatabaseImplement.Models.Worker", "Worker") .WithMany() .HasForeignKey("WorkerId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Evaluation"); + b.Navigation("Worker"); }); + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureCosmetic", b => + { + b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic") + .WithMany() + .HasForeignKey("CosmeticId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") + .WithMany() + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Procedure"); + }); + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b => { b.HasOne("BeautySalonDatabaseImplement.Models.Storekeeper", "Storekeeper") @@ -653,6 +702,11 @@ namespace BeautySalonDatabaseImplement.Migrations b.Navigation("Procedures"); }); + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Evaluation", b => + { + b.Navigation("Procedure"); + }); + modelBuilder.Entity("BeautySalonDatabaseImplement.Models.LaborCosts", b => { b.Navigation("Cosmetics"); diff --git a/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs b/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs index e6b874f..e9bd355 100644 --- a/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs +++ b/BeautySalonView/ClientWebApp/Controllers/ProcedureController.cs @@ -2,6 +2,7 @@ using BeautySalonContracts.BusinessLogicContracts; using BeautySalonContracts.SearchModels; using BeautySalonContracts.ViewModels; +using BeautySalonDatabaseImplement.Models; using Microsoft.AspNetCore.Mvc; using WorkerWebApp; @@ -9,20 +10,22 @@ namespace WorkerWebApp.Controllers { public class ProcedureController : Controller { - private readonly ILogger logger; + private readonly ILogger logger; private readonly ICosmeticLogic cosmetic; + private readonly IEvaluationLogic evaluation; private readonly IProcedureLogic procedure; - public ProcedureController(ILogger logger, ICosmeticLogic cosmetic, IProcedureLogic procedure) + public ProcedureController(ILogger logger, ICosmeticLogic cosmetic, IProcedureLogic procedure, IEvaluationLogic evaluation) { this.logger = logger; this.cosmetic = cosmetic; this.procedure = procedure; + this.evaluation = evaluation; } [HttpGet] - public ProcedureViewModel GetProcedure(int id) + public ProcedureViewModel? GetProcedure(int id) { try { @@ -33,7 +36,7 @@ namespace WorkerWebApp.Controllers } catch (Exception ex) { - logger.LogError(ex, "Ошибка получения процедуры"); + logger.LogError(ex, "Ошибка получения косметики"); throw; } } @@ -46,7 +49,7 @@ namespace WorkerWebApp.Controllers return Redirect("~/Home/Enter"); } - return View(cosmetic.ReadList(null)); + return View(procedure.ReadList(null)); } [HttpGet] @@ -57,7 +60,10 @@ namespace WorkerWebApp.Controllers return Redirect("~/Home/Enter"); } - ViewBag.Cosmetics = cosmetic.ReadList(new CosmeticSearchModel()); + ViewBag.Evaluations = Evaluation.ReadList(new EvaluationSearchModel + { + WorkerId = APIWorker.Worker.Id, + }); return View(); } @@ -95,9 +101,12 @@ namespace WorkerWebApp.Controllers return Redirect("~/Home/Enter"); } - ViewBag.Cosmetics = cosmetic.ReadList(new CosmeticSearchModel()); + ViewBag.Evaluations = Evaluation.ReadList(new EvaluationSearchModel + { + WorkerId = APIWorker.Worker.Id, + }); - return View(procedure.ReadElement(new ProcedureSearchModel + return View(cosmetic.ReadElement(new CosmeticSearchModel { Id = id }));