diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs index 8475ed5..567e9d1 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/ProcedureSearchModel.cs @@ -10,7 +10,6 @@ namespace BeautyStudioContracts.SearchModels { public int? Id { get; set; } public string? ProcedureName { get; set; } - public double? ProcedureCost { get; set; } public string? ProcedureDescription { get; set; } } diff --git a/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs b/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs index b65550f..bd70a14 100644 --- a/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs +++ b/BeautyStudio/BeautyStudioContracts/SearchModels/ServiceSearchModel.cs @@ -10,7 +10,6 @@ namespace BeautyStudioContracts.SearchModels { public int? Id { get; set; } public string? ServiceName { get; set; } - public double? ServicePrice { get; set; } public int? StoreKeeperId { get; set; } } } diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs index 92d0b82..b215f50 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ProcedureViewModel.cs @@ -17,6 +17,10 @@ namespace BeautyStudioContracts.ViewModels [DisplayName("Стоимость процедуры")] public double ProcedureCost { get; set; } [DisplayName("Описание процедуры")] - public string ProcedureDescription { get; set; } = string.Empty; + public string ProcedureDescription { get; set; } = string.Empty; + + public List CosmeticProcedures { get; set; } = new(); + public List OrderProcedures { get; set; } = new(); + public List ServiceProcedure { get; set; } = new(); } } diff --git a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs index 16e54d9..39b888b 100644 --- a/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs +++ b/BeautyStudio/BeautyStudioContracts/ViewModels/ServiceViewModel.cs @@ -17,7 +17,7 @@ namespace BeautyStudioContracts.ViewModels [DisplayName("Стоимость услуги")] public double ServicePrice { get; set; } - + [DisplayName("Сотрудник")] public int StoreKeeperId { get; set; } public List ServiceCosmetic { get; set; } = new(); diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240504094925_InitialCreate.Designer.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240526191135_InitialCreate.Designer.cs similarity index 78% rename from BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240504094925_InitialCreate.Designer.cs rename to BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240526191135_InitialCreate.Designer.cs index e889619..183adbd 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240504094925_InitialCreate.Designer.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240526191135_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace BeautyStudioDatabaseImplement.Migrations { [DbContext(typeof(BeautyStudioDatabase))] - [Migration("20240504094925_InitialCreate")] + [Migration("20240526191135_InitialCreate")] partial class InitialCreate { /// @@ -25,39 +25,6 @@ namespace BeautyStudioDatabaseImplement.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClientEmail") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientLogin") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientPassword") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientPhone") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b => { b.Property("Id") @@ -88,123 +55,7 @@ namespace BeautyStudioDatabaseImplement.Migrations b.ToTable("Cosmetics"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Difficulty") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffId") - .HasColumnType("integer"); - - b.Property("TimeSpent") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("StaffId"); - - b.ToTable("LaborCost"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("integer"); - - b.Property("DateComplete") - .HasColumnType("timestamp with time zone"); - - b.Property("DateCreate") - .HasColumnType("timestamp with time zone"); - - b.Property("ServiceId") - .HasColumnType("integer"); - - b.Property("StaffId") - .IsRequired() - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Sum") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("StaffId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("OrderId") - .HasColumnType("integer"); - - b.Property("ServiceId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("ServiceId"); - - b.ToTable("OrderService"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("integer"); - - b.Property("ProcedureCost") - .HasColumnType("double precision"); - - b.Property("ProcedureDescription") - .IsRequired() - .HasColumnType("text"); - - b.Property("ProcedureName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Procedures"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetics", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -227,7 +78,166 @@ namespace BeautyStudioDatabaseImplement.Migrations b.HasIndex("ProcedureId"); - b.ToTable("ProcedureCosmetics"); + b.ToTable("CosmeticProcedures"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Difficulty") + .IsRequired() + .HasColumnType("text"); + + b.Property("StoreKeeperId") + .HasColumnType("integer"); + + b.Property("TimeSpent") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StoreKeeperId"); + + b.ToTable("LaborCost"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("integer"); + + b.Property("DateComplete") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreate") + .HasColumnType("timestamp with time zone"); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreKeeperId") + .IsRequired() + .HasColumnType("integer"); + + b.Property("Sum") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("integer"); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("OrderId"); + + b.ToTable("OrderCosmetics"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("OrderProcedureCount") + .HasColumnType("integer"); + + b.Property("ProcedureId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("OrderProcedures"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("OrderServiceCount") + .HasColumnType("integer"); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ServiceId"); + + b.ToTable("OrderServices"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ProcedureCost") + .HasColumnType("double precision"); + + b.Property("ProcedureDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("ProcedureName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Procedures"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => @@ -242,19 +252,45 @@ namespace BeautyStudioDatabaseImplement.Migrations .IsRequired() .HasColumnType("text"); - b.Property("StaffId") - .HasColumnType("integer"); - - b.Property("Sum") + b.Property("ServicePrice") .HasColumnType("double precision"); + b.Property("StoreKeeperId") + .HasColumnType("integer"); + b.HasKey("Id"); - b.HasIndex("StaffId"); + b.HasIndex("StoreKeeperId"); b.ToTable("Services"); }); + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("integer"); + + b.Property("ServiceCosmeticCount") + .HasColumnType("integer"); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceCosmetics"); + }); + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b => { b.Property("Id") @@ -269,6 +305,9 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Property("ServiceId") .HasColumnType("integer"); + b.Property("ServiceProcedureCount") + .HasColumnType("integer"); + b.HasKey("Id"); b.HasIndex("ProcedureId"); @@ -278,39 +317,6 @@ namespace BeautyStudioDatabaseImplement.Migrations b.ToTable("ServiceProcedures"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Staff", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StaffEmail") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffFIO") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffLogin") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffPassword") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffPhone") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Staffs"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b => { b.Property("Id") @@ -361,30 +367,72 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Navigation("LaborCost"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b => { - b.HasOne("BeautyStudioDatabaseImplement.Models.Staff", "Staff") - .WithMany("LaborCost") - .HasForeignKey("StaffId") + b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic") + .WithMany("Procedures") + .HasForeignKey("CosmeticId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Staff"); + b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure") + .WithMany("Cosmetics") + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Procedure"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => { - b.HasOne("BeautyStudioDatabaseImplement.Models.Client", null) - .WithMany("Orders") - .HasForeignKey("ClientId") + b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper") + .WithMany() + .HasForeignKey("StoreKeeperId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BeautyStudioDatabaseImplement.Models.Staff", null) + b.Navigation("StoreKeeper"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b => + { + b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic") .WithMany("Orders") - .HasForeignKey("StaffId") + .HasForeignKey("CosmeticId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order") + .WithMany("Cosmetics") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b => + { + b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order") + .WithMany("Procedures") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure") + .WithMany("Orders") + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Procedure"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b => @@ -406,45 +454,34 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Navigation("Service"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => { - b.HasOne("BeautyStudioDatabaseImplement.Models.Client", "Client") + b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper") .WithMany() - .HasForeignKey("ClientId") + .HasForeignKey("StoreKeeperId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Client"); + b.Navigation("StoreKeeper"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetics", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceCosmetic", b => { b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic") - .WithMany("Procedures") + .WithMany("Services") .HasForeignKey("CosmeticId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure") + b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service") .WithMany("Cosmetics") - .HasForeignKey("ProcedureId") + .HasForeignKey("ServiceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Cosmetic"); - b.Navigation("Procedure"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => - { - b.HasOne("BeautyStudioDatabaseImplement.Models.Staff", "Staff") - .WithMany("Services") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Staff"); + b.Navigation("Service"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b => @@ -466,14 +503,13 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Navigation("Service"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b => { + b.Navigation("Orders"); + b.Navigation("Procedures"); + + b.Navigation("Services"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => @@ -483,6 +519,10 @@ namespace BeautyStudioDatabaseImplement.Migrations modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => { + b.Navigation("Cosmetics"); + + b.Navigation("Procedures"); + b.Navigation("Services"); }); @@ -490,25 +530,20 @@ namespace BeautyStudioDatabaseImplement.Migrations { b.Navigation("Cosmetics"); + b.Navigation("Orders"); + b.Navigation("Services"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => { + b.Navigation("Cosmetics"); + b.Navigation("Orders"); b.Navigation("Procedures"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Staff", b => - { - b.Navigation("LaborCost"); - - b.Navigation("Orders"); - - b.Navigation("Services"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b => { b.Navigation("Cosmetics"); diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240504094925_InitialCreate.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240526191135_InitialCreate.cs similarity index 67% rename from BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240504094925_InitialCreate.cs rename to BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240526191135_InitialCreate.cs index 3fa7c42..64aa86d 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240504094925_InitialCreate.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/20240526191135_InitialCreate.cs @@ -13,37 +13,37 @@ namespace BeautyStudioDatabaseImplement.Migrations protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "Clients", + name: "Orders", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ClientLogin = table.Column(type: "text", nullable: false), - ClientFIO = table.Column(type: "text", nullable: false), - ClientEmail = table.Column(type: "text", nullable: false), - ClientPhone = table.Column(type: "text", nullable: false), - ClientPassword = table.Column(type: "text", nullable: false) + DateCreate = table.Column(type: "timestamp with time zone", nullable: false), + DateComplete = table.Column(type: "timestamp with time zone", nullable: true), + Status = table.Column(type: "integer", nullable: false), + Sum = table.Column(type: "double precision", nullable: false), + StoreKeeperId = table.Column(type: "integer", nullable: false), + ServiceId = table.Column(type: "integer", nullable: false), + CosmeticId = table.Column(type: "integer", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Clients", x => x.Id); + table.PrimaryKey("PK_Orders", x => x.Id); }); migrationBuilder.CreateTable( - name: "Staffs", + name: "Procedures", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - StaffFIO = table.Column(type: "text", nullable: false), - StaffEmail = table.Column(type: "text", nullable: false), - StaffLogin = table.Column(type: "text", nullable: false), - StaffPassword = table.Column(type: "text", nullable: false), - StaffPhone = table.Column(type: "text", nullable: false) + ProcedureName = table.Column(type: "text", nullable: false), + ProcedureCost = table.Column(type: "double precision", nullable: false), + ProcedureDescription = table.Column(type: "text", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Staffs", x => x.Id); + table.PrimaryKey("PK_Procedures", x => x.Id); }); migrationBuilder.CreateTable( @@ -64,23 +64,28 @@ namespace BeautyStudioDatabaseImplement.Migrations }); migrationBuilder.CreateTable( - name: "Procedures", + name: "OrderProcedures", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ProcedureName = table.Column(type: "text", nullable: false), - ProcedureCost = table.Column(type: "double precision", nullable: false), - ProcedureDescription = table.Column(type: "text", nullable: false), - ClientId = table.Column(type: "integer", nullable: false) + OrderId = table.Column(type: "integer", nullable: false), + ProcedureId = table.Column(type: "integer", nullable: false), + OrderProcedureCount = table.Column(type: "integer", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Procedures", x => x.Id); + table.PrimaryKey("PK_OrderProcedures", x => x.Id); table.ForeignKey( - name: "FK_Procedures_Clients_ClientId", - column: x => x.ClientId, - principalTable: "Clients", + name: "FK_OrderProcedures_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OrderProcedures_Procedures_ProcedureId", + column: x => x.ProcedureId, + principalTable: "Procedures", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -93,46 +98,15 @@ namespace BeautyStudioDatabaseImplement.Migrations .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), TimeSpent = table.Column(type: "integer", nullable: false), Difficulty = table.Column(type: "text", nullable: false), - StaffId = table.Column(type: "integer", nullable: false) + StoreKeeperId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_LaborCost", x => x.Id); table.ForeignKey( - name: "FK_LaborCost_Staffs_StaffId", - column: x => x.StaffId, - principalTable: "Staffs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(type: "integer", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - DateCreate = table.Column(type: "timestamp with time zone", nullable: false), - DateComplete = table.Column(type: "timestamp with time zone", nullable: true), - Status = table.Column(type: "integer", nullable: false), - Sum = table.Column(type: "double precision", nullable: false), - ClientId = table.Column(type: "integer", nullable: false), - StaffId = table.Column(type: "integer", nullable: false), - ServiceId = table.Column(type: "integer", nullable: false) - }, - 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_Staffs_StaffId", - column: x => x.StaffId, - principalTable: "Staffs", + name: "FK_LaborCost_StoreKeepers_StoreKeeperId", + column: x => x.StoreKeeperId, + principalTable: "StoreKeepers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -144,16 +118,16 @@ namespace BeautyStudioDatabaseImplement.Migrations Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ServiceName = table.Column(type: "text", nullable: false), - Sum = table.Column(type: "double precision", nullable: false), - StaffId = table.Column(type: "integer", nullable: false) + ServicePrice = table.Column(type: "double precision", nullable: false), + StoreKeeperId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Services", x => x.Id); table.ForeignKey( - name: "FK_Services_Staffs_StaffId", - column: x => x.StaffId, - principalTable: "Staffs", + name: "FK_Services_StoreKeepers_StoreKeeperId", + column: x => x.StoreKeeperId, + principalTable: "StoreKeepers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -187,25 +161,26 @@ namespace BeautyStudioDatabaseImplement.Migrations }); migrationBuilder.CreateTable( - name: "OrderService", + name: "OrderServices", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), OrderId = table.Column(type: "integer", nullable: false), - ServiceId = table.Column(type: "integer", nullable: false) + ServiceId = table.Column(type: "integer", nullable: false), + OrderServiceCount = table.Column(type: "integer", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_OrderService", x => x.Id); + table.PrimaryKey("PK_OrderServices", x => x.Id); table.ForeignKey( - name: "FK_OrderService_Orders_OrderId", + name: "FK_OrderServices_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_OrderService_Services_ServiceId", + name: "FK_OrderServices_Services_ServiceId", column: x => x.ServiceId, principalTable: "Services", principalColumn: "Id", @@ -219,7 +194,8 @@ namespace BeautyStudioDatabaseImplement.Migrations Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ServiceId = table.Column(type: "integer", nullable: false), - ProcedureId = table.Column(type: "integer", nullable: false) + ProcedureId = table.Column(type: "integer", nullable: false), + ServiceProcedureCount = table.Column(type: "integer", nullable: false) }, constraints: table => { @@ -239,32 +215,95 @@ namespace BeautyStudioDatabaseImplement.Migrations }); migrationBuilder.CreateTable( - name: "ProcedureCosmetics", + name: "CosmeticProcedures", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ProcedureId = table.Column(type: "integer", nullable: false), CosmeticId = table.Column(type: "integer", nullable: false), + ProcedureId = table.Column(type: "integer", nullable: false), ProcedureCosmeticCount = table.Column(type: "integer", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_ProcedureCosmetics", x => x.Id); + table.PrimaryKey("PK_CosmeticProcedures", x => x.Id); table.ForeignKey( - name: "FK_ProcedureCosmetics_Cosmetics_CosmeticId", + name: "FK_CosmeticProcedures_Cosmetics_CosmeticId", column: x => x.CosmeticId, principalTable: "Cosmetics", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ProcedureCosmetics_Procedures_ProcedureId", + name: "FK_CosmeticProcedures_Procedures_ProcedureId", column: x => x.ProcedureId, principalTable: "Procedures", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "OrderCosmetics", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + OrderId = table.Column(type: "integer", nullable: false), + CosmeticId = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderCosmetics", x => x.Id); + table.ForeignKey( + name: "FK_OrderCosmetics_Cosmetics_CosmeticId", + column: x => x.CosmeticId, + principalTable: "Cosmetics", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_OrderCosmetics_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ServiceCosmetics", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + CosmeticId = table.Column(type: "integer", nullable: false), + ServiceId = table.Column(type: "integer", nullable: false), + ServiceCosmeticCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ServiceCosmetics", x => x.Id); + table.ForeignKey( + name: "FK_ServiceCosmetics_Cosmetics_CosmeticId", + column: x => x.CosmeticId, + principalTable: "Cosmetics", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ServiceCosmetics_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_CosmeticProcedures_CosmeticId", + table: "CosmeticProcedures", + column: "CosmeticId"); + + migrationBuilder.CreateIndex( + name: "IX_CosmeticProcedures_ProcedureId", + table: "CosmeticProcedures", + column: "ProcedureId"); + migrationBuilder.CreateIndex( name: "IX_Cosmetics_LaborCostId", table: "Cosmetics", @@ -276,44 +315,49 @@ namespace BeautyStudioDatabaseImplement.Migrations column: "StoreKeeperId"); migrationBuilder.CreateIndex( - name: "IX_LaborCost_StaffId", + name: "IX_LaborCost_StoreKeeperId", table: "LaborCost", - column: "StaffId"); + column: "StoreKeeperId"); migrationBuilder.CreateIndex( - name: "IX_Orders_ClientId", - table: "Orders", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_StaffId", - table: "Orders", - column: "StaffId"); - - migrationBuilder.CreateIndex( - name: "IX_OrderService_OrderId", - table: "OrderService", - column: "OrderId"); - - migrationBuilder.CreateIndex( - name: "IX_OrderService_ServiceId", - table: "OrderService", - column: "ServiceId"); - - migrationBuilder.CreateIndex( - name: "IX_ProcedureCosmetics_CosmeticId", - table: "ProcedureCosmetics", + name: "IX_OrderCosmetics_CosmeticId", + table: "OrderCosmetics", column: "CosmeticId"); migrationBuilder.CreateIndex( - name: "IX_ProcedureCosmetics_ProcedureId", - table: "ProcedureCosmetics", + name: "IX_OrderCosmetics_OrderId", + table: "OrderCosmetics", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderProcedures_OrderId", + table: "OrderProcedures", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderProcedures_ProcedureId", + table: "OrderProcedures", column: "ProcedureId"); migrationBuilder.CreateIndex( - name: "IX_Procedures_ClientId", - table: "Procedures", - column: "ClientId"); + name: "IX_OrderServices_OrderId", + table: "OrderServices", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_OrderServices_ServiceId", + table: "OrderServices", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceCosmetics_CosmeticId", + table: "ServiceCosmetics", + column: "CosmeticId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceCosmetics_ServiceId", + table: "ServiceCosmetics", + column: "ServiceId"); migrationBuilder.CreateIndex( name: "IX_ServiceProcedures_ProcedureId", @@ -326,19 +370,28 @@ namespace BeautyStudioDatabaseImplement.Migrations column: "ServiceId"); migrationBuilder.CreateIndex( - name: "IX_Services_StaffId", + name: "IX_Services_StoreKeeperId", table: "Services", - column: "StaffId"); + column: "StoreKeeperId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "OrderService"); + name: "CosmeticProcedures"); migrationBuilder.DropTable( - name: "ProcedureCosmetics"); + name: "OrderCosmetics"); + + migrationBuilder.DropTable( + name: "OrderProcedures"); + + migrationBuilder.DropTable( + name: "OrderServices"); + + migrationBuilder.DropTable( + name: "ServiceCosmetics"); migrationBuilder.DropTable( name: "ServiceProcedures"); @@ -360,12 +413,6 @@ namespace BeautyStudioDatabaseImplement.Migrations migrationBuilder.DropTable( name: "StoreKeepers"); - - migrationBuilder.DropTable( - name: "Clients"); - - migrationBuilder.DropTable( - name: "Staffs"); } } } diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/BeautyStudioDatabaseModelSnapshot.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/BeautyStudioDatabaseModelSnapshot.cs index 3304cc9..c7b8235 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/BeautyStudioDatabaseModelSnapshot.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Migrations/BeautyStudioDatabaseModelSnapshot.cs @@ -22,39 +22,6 @@ namespace BeautyStudioDatabaseImplement.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Client", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClientEmail") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientFIO") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientLogin") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientPassword") - .IsRequired() - .HasColumnType("text"); - - b.Property("ClientPhone") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Clients"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b => { b.Property("Id") @@ -85,123 +52,7 @@ namespace BeautyStudioDatabaseImplement.Migrations b.ToTable("Cosmetics"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Difficulty") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffId") - .HasColumnType("integer"); - - b.Property("TimeSpent") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("StaffId"); - - b.ToTable("LaborCost"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("integer"); - - b.Property("DateComplete") - .HasColumnType("timestamp with time zone"); - - b.Property("DateCreate") - .HasColumnType("timestamp with time zone"); - - b.Property("ServiceId") - .HasColumnType("integer"); - - b.Property("StaffId") - .IsRequired() - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Sum") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.HasIndex("StaffId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("OrderId") - .HasColumnType("integer"); - - b.Property("ServiceId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.HasIndex("ServiceId"); - - b.ToTable("OrderService"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClientId") - .HasColumnType("integer"); - - b.Property("ProcedureCost") - .HasColumnType("double precision"); - - b.Property("ProcedureDescription") - .IsRequired() - .HasColumnType("text"); - - b.Property("ProcedureName") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("ClientId"); - - b.ToTable("Procedures"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetics", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -224,7 +75,166 @@ namespace BeautyStudioDatabaseImplement.Migrations b.HasIndex("ProcedureId"); - b.ToTable("ProcedureCosmetics"); + b.ToTable("CosmeticProcedures"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Difficulty") + .IsRequired() + .HasColumnType("text"); + + b.Property("StoreKeeperId") + .HasColumnType("integer"); + + b.Property("TimeSpent") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("StoreKeeperId"); + + b.ToTable("LaborCost"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("integer"); + + b.Property("DateComplete") + .HasColumnType("timestamp with time zone"); + + b.Property("DateCreate") + .HasColumnType("timestamp with time zone"); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("StoreKeeperId") + .IsRequired() + .HasColumnType("integer"); + + b.Property("Sum") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("integer"); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("OrderId"); + + b.ToTable("OrderCosmetics"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("OrderProcedureCount") + .HasColumnType("integer"); + + b.Property("ProcedureId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ProcedureId"); + + b.ToTable("OrderProcedures"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("OrderId") + .HasColumnType("integer"); + + b.Property("OrderServiceCount") + .HasColumnType("integer"); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("ServiceId"); + + b.ToTable("OrderServices"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ProcedureCost") + .HasColumnType("double precision"); + + b.Property("ProcedureDescription") + .IsRequired() + .HasColumnType("text"); + + b.Property("ProcedureName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Procedures"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => @@ -239,19 +249,45 @@ namespace BeautyStudioDatabaseImplement.Migrations .IsRequired() .HasColumnType("text"); - b.Property("StaffId") - .HasColumnType("integer"); - - b.Property("Sum") + b.Property("ServicePrice") .HasColumnType("double precision"); + b.Property("StoreKeeperId") + .HasColumnType("integer"); + b.HasKey("Id"); - b.HasIndex("StaffId"); + b.HasIndex("StoreKeeperId"); b.ToTable("Services"); }); + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceCosmetic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CosmeticId") + .HasColumnType("integer"); + + b.Property("ServiceCosmeticCount") + .HasColumnType("integer"); + + b.Property("ServiceId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CosmeticId"); + + b.HasIndex("ServiceId"); + + b.ToTable("ServiceCosmetics"); + }); + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b => { b.Property("Id") @@ -266,6 +302,9 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Property("ServiceId") .HasColumnType("integer"); + b.Property("ServiceProcedureCount") + .HasColumnType("integer"); + b.HasKey("Id"); b.HasIndex("ProcedureId"); @@ -275,39 +314,6 @@ namespace BeautyStudioDatabaseImplement.Migrations b.ToTable("ServiceProcedures"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Staff", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StaffEmail") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffFIO") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffLogin") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffPassword") - .IsRequired() - .HasColumnType("text"); - - b.Property("StaffPhone") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.ToTable("Staffs"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b => { b.Property("Id") @@ -358,30 +364,72 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Navigation("LaborCost"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.CosmeticProcedure", b => { - b.HasOne("BeautyStudioDatabaseImplement.Models.Staff", "Staff") - .WithMany("LaborCost") - .HasForeignKey("StaffId") + b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic") + .WithMany("Procedures") + .HasForeignKey("CosmeticId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Staff"); + b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure") + .WithMany("Cosmetics") + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Procedure"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => { - b.HasOne("BeautyStudioDatabaseImplement.Models.Client", null) - .WithMany("Orders") - .HasForeignKey("ClientId") + b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper") + .WithMany() + .HasForeignKey("StoreKeeperId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BeautyStudioDatabaseImplement.Models.Staff", null) + b.Navigation("StoreKeeper"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderCosmetic", b => + { + b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic") .WithMany("Orders") - .HasForeignKey("StaffId") + .HasForeignKey("CosmeticId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + + b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order") + .WithMany("Cosmetics") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cosmetic"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderProcedure", b => + { + b.HasOne("BeautyStudioDatabaseImplement.Models.Order", "Order") + .WithMany("Procedures") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure") + .WithMany("Orders") + .HasForeignKey("ProcedureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Procedure"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.OrderService", b => @@ -403,45 +451,34 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Navigation("Service"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Procedure", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => { - b.HasOne("BeautyStudioDatabaseImplement.Models.Client", "Client") + b.HasOne("BeautyStudioDatabaseImplement.Models.StoreKeeper", "StoreKeeper") .WithMany() - .HasForeignKey("ClientId") + .HasForeignKey("StoreKeeperId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Client"); + b.Navigation("StoreKeeper"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ProcedureCosmetics", b => + modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceCosmetic", b => { b.HasOne("BeautyStudioDatabaseImplement.Models.Cosmetic", "Cosmetic") - .WithMany("Procedures") + .WithMany("Services") .HasForeignKey("CosmeticId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BeautyStudioDatabaseImplement.Models.Procedure", "Procedure") + b.HasOne("BeautyStudioDatabaseImplement.Models.Service", "Service") .WithMany("Cosmetics") - .HasForeignKey("ProcedureId") + .HasForeignKey("ServiceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Cosmetic"); - b.Navigation("Procedure"); - }); - - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => - { - b.HasOne("BeautyStudioDatabaseImplement.Models.Staff", "Staff") - .WithMany("Services") - .HasForeignKey("StaffId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Staff"); + b.Navigation("Service"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.ServiceProcedure", b => @@ -463,14 +500,13 @@ namespace BeautyStudioDatabaseImplement.Migrations b.Navigation("Service"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Client", b => - { - b.Navigation("Orders"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Cosmetic", b => { + b.Navigation("Orders"); + b.Navigation("Procedures"); + + b.Navigation("Services"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.LaborCost", b => @@ -480,6 +516,10 @@ namespace BeautyStudioDatabaseImplement.Migrations modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Order", b => { + b.Navigation("Cosmetics"); + + b.Navigation("Procedures"); + b.Navigation("Services"); }); @@ -487,25 +527,20 @@ namespace BeautyStudioDatabaseImplement.Migrations { b.Navigation("Cosmetics"); + b.Navigation("Orders"); + b.Navigation("Services"); }); modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Service", b => { + b.Navigation("Cosmetics"); + b.Navigation("Orders"); b.Navigation("Procedures"); }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.Staff", b => - { - b.Navigation("LaborCost"); - - b.Navigation("Orders"); - - b.Navigation("Services"); - }); - modelBuilder.Entity("BeautyStudioDatabaseImplement.Models.StoreKeeper", b => { b.Navigation("Cosmetics"); diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs index 97824d8..bed96b7 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Procedure.cs @@ -26,17 +26,17 @@ namespace BeautyStudioDatabaseImplement.Models // связь процедур и косметики многие - ко - многим [ForeignKey("ProcedureId")] - public virtual List Cosmetics { get; set; } = new(); + public virtual List Cosmetics { get; set; } = new(); - private List? _cosmeticProcedures = null; + private List? _cosmeticProcedures = null; [NotMapped] - public List CosmeticProcedures + public List CosmeticProcedures { get { _cosmeticProcedures ??= Cosmetics - .Select(pc => new ProcedureCosmeticsViewModel(pc.Cosmetic.GetViewModel, pc.Procedure.GetViewModel, pc.ProcedureCosmeticCount)) + .Select(pc => new CosmeticProcedureViewModel(pc.Cosmetic.GetViewModel, pc.Procedure.GetViewModel, pc.ProcedureCosmeticCount)) .ToList(); return _cosmeticProcedures; } @@ -79,6 +79,7 @@ namespace BeautyStudioDatabaseImplement.Models ProcedureName = ProcedureName, ProcedureCost = ProcedureCost, ProcedureDescription = ProcedureDescription, + CosmeticProcedures = CosmeticProcedures }; public void UpdateCosmetics(BeautyStudioDatabase context, ProcedureBindingModel model) diff --git a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs index e49ba26..5d930d6 100644 --- a/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs +++ b/BeautyStudio/BeautyStudioDatabaseImplement/Models/Service.cs @@ -72,7 +72,18 @@ namespace BeautyStudioDatabaseImplement.Models { Id = model.Id, ServiceName = model.ServiceName, - ServicePrice = model.ServicePrice + ServicePrice = model.ServicePrice, + Cosmetics = model.ServiceCosmetic.Select(x => new ServiceCosmetic() + { + Cosmetic = context.Cosmetics.First(y => y.Id == x.Cosmetic.Id), + ServiceCosmeticCount = x.Count + }).ToList(), + Procedures = model.ServiceProcedure.Select(x => new ServiceProcedure() + { + Procedure = context.Procedures.First(y => y.Id == x.Procedure.Id), + ServiceProcedureCount = x.Count + }).ToList(), + StoreKeeperId = model.StoreKeeperId }; } @@ -80,13 +91,17 @@ namespace BeautyStudioDatabaseImplement.Models { ServiceName = model.ServiceName; ServicePrice = model.ServicePrice; + StoreKeeperId = model.StoreKeeperId; } public ServiceViewModel GetViewModel => new() { Id = Id, ServiceName = ServiceName, - ServicePrice = ServicePrice + ServicePrice = ServicePrice, + ServiceCosmetic = ServiceCosmetics, + ServiceProcedure = ServiceProcedures, + StoreKeeperId = StoreKeeperId }; public void UpdateCosmetics(BeautyStudioDatabase context, ServiceBindingModel model) diff --git a/BeautyStudio/BeautyStudioView/FormCosmetics.cs b/BeautyStudio/BeautyStudioView/FormCosmetics.cs index bfaf13e..beb13d1 100644 --- a/BeautyStudio/BeautyStudioView/FormCosmetics.cs +++ b/BeautyStudio/BeautyStudioView/FormCosmetics.cs @@ -3,7 +3,6 @@ using BeautyStudioContracts.BusinessLogicContracts; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; -using System.CosmeticModel; using System.Data; using System.Drawing; using System.Linq; diff --git a/BeautyStudio/BeautyStudioView/Program.cs b/BeautyStudio/BeautyStudioView/Program.cs index 78ffda0..f3250ef 100644 --- a/BeautyStudio/BeautyStudioView/Program.cs +++ b/BeautyStudio/BeautyStudioView/Program.cs @@ -4,6 +4,7 @@ using BeautyStudioContracts.BusinessLogicContracts; using BeautyStudioContracts.StoragesContracts; using BeautyStudioDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; namespace BeautyStudioView @@ -34,36 +35,24 @@ namespace BeautyStudioView option.SetMinimumLevel(LogLevel.Information); option.AddNLog("nlog.config"); }); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + ////services.AddTransient(); + ////services.AddTransient(); + ////services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); } } } \ No newline at end of file