чиним бд

This commit is contained in:
Milana Ievlewa 2024-04-30 17:52:04 +03:00
parent e52bbb71a1
commit fcbef081b9
8 changed files with 1739 additions and 56 deletions

View File

@ -1,82 +1,69 @@
using Microsoft.AspNetCore.Http;
using BeautySalonBusinessLogic.BusinessLogics;
using BeautySalonContracts.BindingModels;
using BeautySalonContracts.BusinessLogicContracts;
using BeautySalonContracts.SearchModels;
using BeautySalonContracts.ViewModels;
using Microsoft.AspNetCore.Mvc;
namespace BeatySalonRestApi.Controllers
namespace BeautySalonRestApi.Controllers
{
public class ClientControlles : Controller
[Route("api/[controller]/[action]")]
[ApiController]
public class ClientController : Controller
{
// GET: ClientControlles
public ActionResult Index()
private readonly ILogger _logger;
private readonly IClientLogic _logic;
public ClientController(IClientLogic logic, ILogger<ClientController> logger)
{
return View();
_logger = logger;
_logic = logic;
}
// GET: ClientControlles/Details/5
public ActionResult Details(int id)
{
return View();
}
// GET: ClientControlles/Create
public ActionResult Create()
{
return View();
}
// POST: ClientControlles/Create
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(IFormCollection collection)
[HttpGet]
public ClientViewModel? Login(string login, string password)
{
try
{
return RedirectToAction(nameof(Index));
return _logic.ReadElement(new ClientSearchModel
{
ClientLogin = login,
ClientPassword = password
});
}
catch
catch (Exception ex)
{
return View();
_logger.LogError(ex, "Ошибка входа в систему");
throw;
}
}
// GET: ClientControlles/Edit/5
public ActionResult Edit(int id)
{
return View();
}
// POST: ClientControlles/Edit/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(int id, IFormCollection collection)
public void Register(ClientBindingModel model)
{
try
{
return RedirectToAction(nameof(Index));
_logic.Create(model);
}
catch
catch (Exception ex)
{
return View();
_logger.LogError(ex, "Ошибка регистрации");
throw;
}
}
// GET: ClientControlles/Delete/5
public ActionResult Delete(int id)
{
return View();
}
// POST: ClientControlles/Delete/5
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id, IFormCollection collection)
public void UpdateData(ClientBindingModel model)
{
try
{
return RedirectToAction(nameof(Index));
_logic.Update(model);
}
catch
catch (Exception ex)
{
return View();
_logger.LogError(ex, "Ошибка обновления данных");
throw;
}
}
}

View File

@ -10,15 +10,18 @@ namespace BeautySalonContracts.ViewModels
{
public class EvaluationViewModel : IEvaluationModel
{
public int Id { get; set; }
[DisplayName("Баллы за процедуру")]
public double PointsProcedure { get; set; }
[DisplayName("Баллы за косметику")]
public double PointsCosmetics { get; set; }
public int ClientId { get; set; }
public int Id { get; set; }
public string Client_Name { get; set; } = string.Empty;
public int ProcedureId { get; set; }
public string ProcedureName { get; set; } = string.Empty;
public string Procedure_Name { get; set; } = string.Empty;
}
}

View File

@ -19,6 +19,7 @@ namespace BeautySalonDatabaseImplement.Implements
using var context = new BeautySalonDatabase();
return context.Evaluations
.Include(x => x.Procedure)
.Include(x => x.Client)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
@ -31,6 +32,7 @@ namespace BeautySalonDatabaseImplement.Implements
{
return context.Evaluations
.Include(x => x.Procedure)
.Include(x => x.Client)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
@ -39,6 +41,7 @@ namespace BeautySalonDatabaseImplement.Implements
{
return context.Evaluations
.Include(x => x.Procedure)
.Include(x => x.Client)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
@ -55,6 +58,7 @@ namespace BeautySalonDatabaseImplement.Implements
using var context = new BeautySalonDatabase();
return context.Evaluations
.Include(x => x.Procedure)
.Include(x => x.Client)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
@ -71,6 +75,7 @@ namespace BeautySalonDatabaseImplement.Implements
context.SaveChanges();
return context.Evaluations
.Include(x => x.Procedure)
.Include(x => x.Client)
.FirstOrDefault(x => x.Id == newRating.Id)
?.GetViewModel;
}
@ -80,6 +85,7 @@ namespace BeautySalonDatabaseImplement.Implements
using var context = new BeautySalonDatabase();
var сosmetic = context.Evaluations
.Include(x => x.Procedure)
.Include(x => x.Client)
.FirstOrDefault(x => x.Id == model.Id);
if (сosmetic == null)
{
@ -95,6 +101,7 @@ namespace BeautySalonDatabaseImplement.Implements
using var context = new BeautySalonDatabase();
var element = context.Evaluations
.Include(x => x.Procedure)
.Include(x => x.Client)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{

View File

@ -0,0 +1,615 @@
// <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("20240430144857_InitialCreate")]
partial class InitialCreate
{
/// <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.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
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.HasKey("Id");
b.HasIndex("LaborCostId");
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>("ProcedureCosmeticCount")
.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<int>("ClientId")
.HasColumnType("int");
b.Property<double>("PointsCosmetics")
.HasColumnType("float");
b.Property<double>("PointsProcedure")
.HasColumnType("float");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ProcedureId");
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>("StaffMemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StaffMemberId");
b.ToTable("LaborCosts");
});
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.Property<int?>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("OrderId");
b.HasIndex("ProcedureId");
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<int>("ClientId")
.HasColumnType("int");
b.Property<double>("OrderAmount")
.HasColumnType("float");
b.Property<DateTime>("OrderDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("ClientId");
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>("ClientId")
.HasColumnType("int");
b.Property<string>("ProcedureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("ProcedurePrice")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Procedures");
});
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>("StaffMemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StaffMemberId");
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>("ServiceCosmeticCount")
.HasColumnType("int");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("ServiceId");
b.ToTable("ServiceCosmetics");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.StaffMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("StaffMemberEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberPhone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberSpecialty")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberSurname")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("StaffMembers");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.LaborCosts", "LaborCost")
.WithMany("Cosmetics")
.HasForeignKey("LaborCostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LaborCost");
});
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.Client", "Client")
.WithMany("Evaluations")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
.WithMany("Evaluations")
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Procedure");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.LaborCosts", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.StaffMember", "StaffMember")
.WithMany("LaborsCosts")
.HasForeignKey("StaffMemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("StaffMember");
});
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.HasOne("BeautySalonDatabaseImplement.Models.Procedure", null)
.WithMany("Orders")
.HasForeignKey("ProcedureId");
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("Orders")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Service");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Order_", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
.WithMany("Procedures")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.StaffMember", "StaffMember")
.WithMany("Services")
.HasForeignKey("StaffMemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("StaffMember");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceCosmetic", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
.WithMany("Services")
.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.Client", b =>
{
b.Navigation("Evaluations");
b.Navigation("Orders");
b.Navigation("Procedures");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
{
b.Navigation("Procedures");
b.Navigation("Services");
});
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");
b.Navigation("Evaluations");
b.Navigation("Orders");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
{
b.Navigation("Cosmetics");
b.Navigation("Orders");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.StaffMember", b =>
{
b.Navigation("LaborsCosts");
b.Navigation("Services");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,457 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BeautySalonDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
ClientEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
ClientPassword = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "StaffMembers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StaffMemberName = table.Column<string>(type: "nvarchar(max)", nullable: false),
StaffMemberSurname = table.Column<string>(type: "nvarchar(max)", nullable: false),
StaffMemberSpecialty = table.Column<string>(type: "nvarchar(max)", nullable: false),
StaffMemberLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
StaffMemberEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
StaffMemberPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
StaffMemberPhone = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_StaffMembers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrderDate = table.Column<DateTime>(type: "datetime2", nullable: false),
OrderAmount = table.Column<double>(type: "float", nullable: false),
ClientId = table.Column<int>(type: "int", 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);
});
migrationBuilder.CreateTable(
name: "Procedures",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProcedureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
ProcedurePrice = table.Column<double>(type: "float", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Procedures", x => x.Id);
table.ForeignKey(
name: "FK_Procedures_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "LaborCosts",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
NumberHours = table.Column<int>(type: "int", nullable: false),
Difficulty = table.Column<string>(type: "nvarchar(max)", nullable: false),
StaffMemberId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_LaborCosts", x => x.Id);
table.ForeignKey(
name: "FK_LaborCosts_StaffMembers_StaffMemberId",
column: x => x.StaffMemberId,
principalTable: "StaffMembers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Services",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ServiceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
ServicePrice = table.Column<double>(type: "float", nullable: false),
StaffMemberId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Services", x => x.Id);
table.ForeignKey(
name: "FK_Services_StaffMembers_StaffMemberId",
column: x => x.StaffMemberId,
principalTable: "StaffMembers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Evaluations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PointsProcedure = table.Column<double>(type: "float", nullable: false),
PointsCosmetics = table.Column<double>(type: "float", nullable: false),
ProcedureId = table.Column<int>(type: "int", nullable: false),
ClientId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Evaluations", x => x.Id);
table.ForeignKey(
name: "FK_Evaluations_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Evaluations_Procedures_ProcedureId",
column: x => x.ProcedureId,
principalTable: "Procedures",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrderProcedures",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrderId = table.Column<int>(type: "int", nullable: false),
ProcedureId = table.Column<int>(type: "int", nullable: false),
OrderProcedureCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderProcedures", x => x.Id);
table.ForeignKey(
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);
});
migrationBuilder.CreateTable(
name: "Cosmetics",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Brand = table.Column<string>(type: "nvarchar(max)", nullable: false),
CosmeticName = table.Column<string>(type: "nvarchar(max)", nullable: false),
CosmeticPrice = table.Column<double>(type: "float", nullable: false),
LaborCostId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cosmetics", x => x.Id);
table.ForeignKey(
name: "FK_Cosmetics_LaborCosts_LaborCostId",
column: x => x.LaborCostId,
principalTable: "LaborCosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "OrderServices",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrderId = table.Column<int>(type: "int", nullable: false),
ServiceId = table.Column<int>(type: "int", nullable: false),
OrderServiceCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderServices", x => x.Id);
table.ForeignKey(
name: "FK_OrderServices_Orders_OrderId",
column: x => x.OrderId,
principalTable: "Orders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_OrderServices_Services_ServiceId",
column: x => x.ServiceId,
principalTable: "Services",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "CosmeticProcedures",
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),
ProcedureCosmeticCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CosmeticProcedures", x => x.Id);
table.ForeignKey(
name: "FK_CosmeticProcedures_Cosmetics_CosmeticId",
column: x => x.CosmeticId,
principalTable: "Cosmetics",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrderId = table.Column<int>(type: "int", nullable: false),
CosmeticId = table.Column<int>(type: "int", nullable: false),
ProcedureId = table.Column<int>(type: "int", nullable: true)
},
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);
table.ForeignKey(
name: "FK_OrderCosmetics_Procedures_ProcedureId",
column: x => x.ProcedureId,
principalTable: "Procedures",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "ServiceCosmetics",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CosmeticId = table.Column<int>(type: "int", nullable: false),
ServiceId = table.Column<int>(type: "int", nullable: false),
ServiceCosmeticCount = table.Column<int>(type: "int", 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",
column: "LaborCostId");
migrationBuilder.CreateIndex(
name: "IX_Evaluations_ClientId",
table: "Evaluations",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Evaluations_ProcedureId",
table: "Evaluations",
column: "ProcedureId");
migrationBuilder.CreateIndex(
name: "IX_LaborCosts_StaffMemberId",
table: "LaborCosts",
column: "StaffMemberId");
migrationBuilder.CreateIndex(
name: "IX_OrderCosmetics_CosmeticId",
table: "OrderCosmetics",
column: "CosmeticId");
migrationBuilder.CreateIndex(
name: "IX_OrderCosmetics_OrderId",
table: "OrderCosmetics",
column: "OrderId");
migrationBuilder.CreateIndex(
name: "IX_OrderCosmetics_ProcedureId",
table: "OrderCosmetics",
column: "ProcedureId");
migrationBuilder.CreateIndex(
name: "IX_OrderProcedures_OrderId",
table: "OrderProcedures",
column: "OrderId");
migrationBuilder.CreateIndex(
name: "IX_OrderProcedures_ProcedureId",
table: "OrderProcedures",
column: "ProcedureId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_OrderServices_OrderId",
table: "OrderServices",
column: "OrderId");
migrationBuilder.CreateIndex(
name: "IX_OrderServices_ServiceId",
table: "OrderServices",
column: "ServiceId");
migrationBuilder.CreateIndex(
name: "IX_Procedures_ClientId",
table: "Procedures",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_ServiceCosmetics_CosmeticId",
table: "ServiceCosmetics",
column: "CosmeticId");
migrationBuilder.CreateIndex(
name: "IX_ServiceCosmetics_ServiceId",
table: "ServiceCosmetics",
column: "ServiceId");
migrationBuilder.CreateIndex(
name: "IX_Services_StaffMemberId",
table: "Services",
column: "StaffMemberId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "CosmeticProcedures");
migrationBuilder.DropTable(
name: "Evaluations");
migrationBuilder.DropTable(
name: "OrderCosmetics");
migrationBuilder.DropTable(
name: "OrderProcedures");
migrationBuilder.DropTable(
name: "OrderServices");
migrationBuilder.DropTable(
name: "ServiceCosmetics");
migrationBuilder.DropTable(
name: "Procedures");
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Cosmetics");
migrationBuilder.DropTable(
name: "Services");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "LaborCosts");
migrationBuilder.DropTable(
name: "StaffMembers");
}
}
}

View File

@ -0,0 +1,612 @@
// <auto-generated />
using System;
using BeautySalonDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace BeautySalonDatabaseImplement.Migrations
{
[DbContext(typeof(BeautySalonDatabase))]
partial class BeautySalonDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.17")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
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.HasKey("Id");
b.HasIndex("LaborCostId");
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>("ProcedureCosmeticCount")
.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<int>("ClientId")
.HasColumnType("int");
b.Property<double>("PointsCosmetics")
.HasColumnType("float");
b.Property<double>("PointsProcedure")
.HasColumnType("float");
b.Property<int>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ProcedureId");
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>("StaffMemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StaffMemberId");
b.ToTable("LaborCosts");
});
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.Property<int?>("ProcedureId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("OrderId");
b.HasIndex("ProcedureId");
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<int>("ClientId")
.HasColumnType("int");
b.Property<double>("OrderAmount")
.HasColumnType("float");
b.Property<DateTime>("OrderDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("ClientId");
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>("ClientId")
.HasColumnType("int");
b.Property<string>("ProcedureName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("ProcedurePrice")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Procedures");
});
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>("StaffMemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StaffMemberId");
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>("ServiceCosmeticCount")
.HasColumnType("int");
b.Property<int>("ServiceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CosmeticId");
b.HasIndex("ServiceId");
b.ToTable("ServiceCosmetics");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.StaffMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("StaffMemberEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberPhone")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberSpecialty")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("StaffMemberSurname")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("StaffMembers");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.LaborCosts", "LaborCost")
.WithMany("Cosmetics")
.HasForeignKey("LaborCostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("LaborCost");
});
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.Client", "Client")
.WithMany("Evaluations")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure")
.WithMany("Evaluations")
.HasForeignKey("ProcedureId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Procedure");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.LaborCosts", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.StaffMember", "StaffMember")
.WithMany("LaborsCosts")
.HasForeignKey("StaffMemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("StaffMember");
});
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.HasOne("BeautySalonDatabaseImplement.Models.Procedure", null)
.WithMany("Orders")
.HasForeignKey("ProcedureId");
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("Orders")
.HasForeignKey("ServiceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Service");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Order_", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Procedure", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.Client", "Client")
.WithMany("Procedures")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.StaffMember", "StaffMember")
.WithMany("Services")
.HasForeignKey("StaffMemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("StaffMember");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.ServiceCosmetic", b =>
{
b.HasOne("BeautySalonDatabaseImplement.Models.Cosmetic", "Cosmetic")
.WithMany("Services")
.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.Client", b =>
{
b.Navigation("Evaluations");
b.Navigation("Orders");
b.Navigation("Procedures");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Cosmetic", b =>
{
b.Navigation("Procedures");
b.Navigation("Services");
});
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");
b.Navigation("Evaluations");
b.Navigation("Orders");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.Service", b =>
{
b.Navigation("Cosmetics");
b.Navigation("Orders");
});
modelBuilder.Entity("BeautySalonDatabaseImplement.Models.StaffMember", b =>
{
b.Navigation("LaborsCosts");
b.Navigation("Services");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -22,12 +22,11 @@ namespace BeautySalonDatabaseImplement.Models
[Required]
public int ProcedureId { get; set; }
public virtual Procedure Procedure { get; set; } = new();
[Required]
public int ClientId { get; set; }
public virtual Client Client { get; set; }
public virtual Procedure Procedure { get; set; }
public virtual Client Client { get; set; } = new();
public static Evaluation? Create(EvaluationBindingModel? model)
{
@ -63,7 +62,8 @@ namespace BeautySalonDatabaseImplement.Models
PointsCosmetics=PointsCosmetics,
ProcedureId=ProcedureId,
ClientId=ClientId,
ProcedureName = Procedure.ProcedureName
Procedure_Name = Procedure.ProcedureName,
Client_Name = Client.ClientFIO
};
}
}

View File

@ -55,6 +55,7 @@ namespace BeautySalonDatabaseImplement.Models
}
}
[NotMapped]
public List<OrderCosmeticViewModel> OrderCosmetics
{
get
@ -114,6 +115,7 @@ namespace BeautySalonDatabaseImplement.Models
OrderAmount = OrderAmount,
OrderServices = OrderServices,
OrderProcedures = OrderProcedures,
OrderCosmetics = OrderCosmetics,
ClientId = ClientId
};