Всё работает
This commit is contained in:
parent
0157390a30
commit
063dd7bb81
@ -127,10 +127,10 @@ namespace FoodOrdersDatabaseImplement.Implements
|
||||
|
||||
foreach (var shopDish in ListShopDish)
|
||||
{
|
||||
if (count - shopDish.Count >= 0)
|
||||
if (count - shopDish.Count > 0)
|
||||
{
|
||||
count -= shopDish.Count;
|
||||
ListShopDish.Remove(shopDish);
|
||||
shopDish.Count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
246
FoodOrders/FoodOrdersDatabaseImplement/Migrations/20230323201720_HardLabWork03.Designer.cs
generated
Normal file
246
FoodOrders/FoodOrdersDatabaseImplement/Migrations/20230323201720_HardLabWork03.Designer.cs
generated
Normal file
@ -0,0 +1,246 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FoodOrdersDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FoodOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(FoodOrdersDatabase))]
|
||||
[Migration("20230323201720_HardLabWork03")]
|
||||
partial class HardLabWork03
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Dish", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("DishName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Dishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DishId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("DishId");
|
||||
|
||||
b.ToTable("DishComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("DishId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DishId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateOfOpening")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DishId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DishId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopDishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
||||
{
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("DishComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Dish");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany()
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dish");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||
{
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany()
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Dishes")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dish");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("DishComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Dish", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Dishes");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FoodOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class HardLabWork03 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateOfOpening = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
Capacity = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopDishes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||
DishId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopDishes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopDishes_Dishes_DishId",
|
||||
column: x => x.DishId,
|
||||
principalTable: "Dishes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopDishes_Shops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "Shops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopDishes_DishId",
|
||||
table: "ShopDishes",
|
||||
column: "DishId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopDishes_ShopId",
|
||||
table: "ShopDishes",
|
||||
column: "ShopId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopDishes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
}
|
||||
}
|
||||
}
|
@ -121,6 +121,59 @@ namespace FoodOrdersDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateOfOpening")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("DishId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("DishId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopDishes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
||||
{
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Component", "Component")
|
||||
@ -151,6 +204,25 @@ namespace FoodOrdersDatabaseImplement.Migrations
|
||||
b.Navigation("Dish");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||
{
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||
.WithMany()
|
||||
.HasForeignKey("DishId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FoodOrdersDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Dishes")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Dish");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("DishComponents");
|
||||
@ -160,6 +232,11 @@ namespace FoodOrdersDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Dishes");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user