diff --git a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.Designer.cs b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.Designer.cs
similarity index 98%
rename from ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.Designer.cs
rename to ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.Designer.cs
index d19d47f..9491b2a 100644
--- a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.Designer.cs
+++ b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.Designer.cs
@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations
{
[DbContext(typeof(ConfectioneryDatabase))]
- [Migration("20230304103151_add_entity_client")]
- partial class add_entity_client
+ [Migration("20230307072144_add_client")]
+ partial class add_client
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
diff --git a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.cs b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs
similarity index 95%
rename from ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.cs
rename to ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs
index 262ea63..d125130 100644
--- a/ConfectioneryDatabaseImplement/Migrations/20230304103151_add_entity_client.cs
+++ b/ConfectioneryDatabaseImplement/Migrations/20230307072144_add_client.cs
@@ -5,11 +5,12 @@
namespace ConfectioneryDatabaseImplement.Migrations
{
///
- public partial class add_entity_client : Migration
+ public partial class add_client : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.Sql("TRUNCATE Orders");
migrationBuilder.AddColumn(
name: "ClientId",
table: "Orders",
diff --git a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
index f4abd73..af78da0 100644
--- a/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
+++ b/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs
@@ -10,17 +10,17 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations
{
- [DbContext(typeof(ConfectioneryDatabase))]
- partial class ConfectioneryDatabaseModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
+ [DbContext(typeof(ConfectioneryDatabase))]
+ partial class ConfectioneryDatabaseModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "7.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b =>
{
@@ -28,7 +28,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("int");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("ClientFIO")
.IsRequired()
@@ -59,21 +59,21 @@ namespace ConfectioneryDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
- b.Property("Cost")
- .HasColumnType("float");
+ b.Property("Cost")
+ .HasColumnType("float");
- b.HasKey("Id");
+ b.HasKey("Id");
- b.ToTable("Components");
- });
+ b.ToTable("Components");
+ });
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("ClientId")
.HasColumnType("int");
@@ -81,75 +81,75 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Property("Count")
.HasColumnType("int");
- b.Property("DateCreate")
- .HasColumnType("datetime2");
+ b.Property("DateCreate")
+ .HasColumnType("datetime2");
- b.Property("DateImplement")
- .HasColumnType("datetime2");
+ b.Property("DateImplement")
+ .HasColumnType("datetime2");
- b.Property("PastryId")
- .HasColumnType("int");
+ b.Property("PastryId")
+ .HasColumnType("int");
- b.Property("Status")
- .HasColumnType("int");
+ b.Property("Status")
+ .HasColumnType("int");
- b.Property("Sum")
- .HasColumnType("float");
+ b.Property("Sum")
+ .HasColumnType("float");
- b.HasKey("Id");
+ b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("PastryId");
- b.ToTable("Orders");
- });
+ b.ToTable("Orders");
+ });
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
- b.Property("PastryName")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
+ b.Property("PastryName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
- b.Property("Price")
- .HasColumnType("float");
+ b.Property("Price")
+ .HasColumnType("float");
- b.HasKey("Id");
+ b.HasKey("Id");
b.ToTable("Pastries");
});
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
- b.Property("ComponentId")
- .HasColumnType("int");
+ b.Property("ComponentId")
+ .HasColumnType("int");
- b.Property("Count")
- .HasColumnType("int");
+ b.Property("Count")
+ .HasColumnType("int");
- b.Property("PastryId")
- .HasColumnType("int");
+ b.Property("PastryId")
+ .HasColumnType("int");
- b.HasKey("Id");
+ b.HasKey("Id");
- b.HasIndex("ComponentId");
+ b.HasIndex("ComponentId");
- b.HasIndex("PastryId");
+ b.HasIndex("PastryId");
- b.ToTable("PastryComponents");
- });
+ b.ToTable("PastryComponents");
+ });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Shop", b =>
{
@@ -236,11 +236,11 @@ namespace ConfectioneryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
- .WithMany("Components")
- .HasForeignKey("PastryId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
+ b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
+ .WithMany("Components")
+ .HasForeignKey("PastryId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
b.Navigation("Component");
@@ -283,9 +283,9 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("PastryComponents");
});
- modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
- {
- b.Navigation("Components");
+ modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
+ {
+ b.Navigation("Components");
b.Navigation("Orders");
@@ -297,6 +297,6 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("ShopPastries");
});
#pragma warning restore 612, 618
- }
- }
+ }
+ }
}
diff --git a/ConfectioneryDatabaseImplement/Order.cs b/ConfectioneryDatabaseImplement/Order.cs
index 9859bee..3c815b4 100644
--- a/ConfectioneryDatabaseImplement/Order.cs
+++ b/ConfectioneryDatabaseImplement/Order.cs
@@ -84,8 +84,7 @@ namespace ConfectioneryDatabaseImplement.Models
return new()
{
PastryName = context.Pastries.FirstOrDefault(x => x.Id == PastryId)?.PastryName ?? string.Empty,
- // ??????
- ClientFIO = Client?.ClientFIO ?? context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty,
+ ClientFIO = Client?.ClientFIO ?? string.Empty,
PastryId = PastryId,
Count = Count,
Sum = Sum,