Я всегда твердил, что судьба — игра.

Что зачем нам рыба, раз есть икра.
Что готический стиль победит, как школа,
как способность торчать, избежав укола.
Я сижу у окна. За окном осина.
Я любил немногих. Однако — сильно.
This commit is contained in:
Allllen4a 2024-05-31 23:21:44 +04:00
parent 25e6359e0a
commit 1cda9ec164
5 changed files with 941 additions and 18 deletions

View File

@ -22,6 +22,13 @@ namespace BeautySalonDatabaseImplement
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Evaluation>()
.HasOne(e => e.Procedure)
.WithOne(p => p.Evaluation)
.HasForeignKey<Procedure>(p => p.EvaluationId);
}
public virtual DbSet<Order_> Orders { set; get; }
public virtual DbSet<LaborCosts> LaborCosts { set; get; }

View File

@ -0,0 +1,741 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("CosmeticName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("CosmeticPrice")
.HasColumnType("float");
b.Property<int>("LaborCostId")
.HasColumnType("int");
b.Property<int>("StorekeeperId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("LaborCostId");
b.HasIndex("StorekeeperId");
b.ToTable("Cosmetics");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.CosmeticProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CosmeticId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("ProcedureId");
b.ToTable("CosmeticProcedures");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Evaluation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("PointsCosmetics")
.HasColumnType("float");
b.Property<double>("PointsProcedure")
.HasColumnType("float");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.Property<int>("WorkerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("Evaluations");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.LaborCosts", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Difficulty")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("NumberHours")
.HasColumnType("int");
b.Property<int>("StorekeeperId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StorekeeperId");
b.ToTable("LaborCosts");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.MessageInfo", b =>
{
b.Property<string>("MessageId")
.HasColumnType("nvarchar(450)");
b.Property<string>("Body")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("DateDelivery")
.HasColumnType("datetime2");
b.Property<string>("SenderName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("StorekeeperId")
.HasColumnType("int");
b.Property<string>("Subject")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("WorkerId")
.HasColumnType("int");
b.HasKey("MessageId");
b.HasIndex("StorekeeperId");
b.HasIndex("WorkerId");
b.ToTable("MessageInfos");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderCosmetic", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CosmeticId")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("OrderId");
b.ToTable("OrderCosmetics");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("OrderProcedureCount")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("ProcedureId");
b.ToTable("OrderProcedures");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.OrderService", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("OrderServiceCount")
.HasColumnType("int");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("ServiceId");
b.ToTable("OrderServices");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Order_", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<double>("OrderAmount")
.HasColumnType("float");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int>("WorkerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("WorkerId");
b.ToTable("Orders");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("EvaluationId")
.HasColumnType("int");
b.Property<double>("ProcedureDuration")
.HasColumnType("float");
b.Property<string>("ProcedureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("ProcedurePrice")
.HasColumnType("float");
b.Property<int>("WorkerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("EvaluationId")
.IsUnique();
b.HasIndex("WorkerId");
b.ToTable("Procedures");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ProcedureCosmetic", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CosmeticId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("ProcedureId");
b.ToTable("ProcedureCosmetics");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ServiceName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("ServicePrice")
.HasColumnType("float");
b.Property<int>("StorekeeperId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StorekeeperId");
b.ToTable("Services");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceCosmetic", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CosmeticId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("ServiceId");
b.ToTable("ServiceCosmetics");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceProcedure", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProcedureId");
b.HasIndex("ServiceId");
b.ToTable("ServiceProcedures");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Storekeeper", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("Password")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.HasKey("Id");
b.ToTable("Storekeepers");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("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
}
}
}

View File

@ -0,0 +1,112 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BeautySalonDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class HZmigration : Migration
{
/// <inheritdoc />
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<int>(
name: "EvaluationId",
table: "Procedures",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "ProcedureCosmetics",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CosmeticId = table.Column<int>(type: "int", nullable: false),
ProcedureId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(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);
}
/// <inheritdoc />
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);
}
}
}

View File

@ -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<int>("Id"));
b.Property<int>("EvaluationId")
.HasColumnType("int");
b.Property<double>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CosmeticId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("ProcedureId");
b.ToTable("ProcedureCosmetics");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
{
b.Property<int>("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");

View File

@ -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<ProcedureController> logger;
private readonly ILogger logger;
private readonly ICosmeticLogic cosmetic;
private readonly IEvaluationLogic evaluation;
private readonly IProcedureLogic procedure;
public ProcedureController(ILogger<ProcedureController> logger, ICosmeticLogic cosmetic, IProcedureLogic procedure)
public ProcedureController(ILogger<ProcedureController> 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
}));