Add view models

This commit is contained in:
ShabOl 2024-05-15 21:14:04 +04:00
parent f2b3b0f4ff
commit ace7c9d1c0
21 changed files with 1074 additions and 8 deletions

View File

@ -7,7 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarView", "SushiBarVie
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarDataModels", "SushiBarDataModels\SushiBarDataModels.csproj", "{4A5A85B2-9B70-4493-B550-0E29FE82E9FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarDatabaseImplement", "SushiBarDatabaseImplement\SushiBarDatabaseImplement.csproj", "{135C846B-59EC-4803-B07C-8991C60C57D6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarDatabaseImplement", "SushiBarDatabaseImplement\SushiBarDatabaseImplement.csproj", "{135C846B-59EC-4803-B07C-8991C60C57D6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarContracts", "SushiBarContracts\SushiBarContracts.csproj", "{25C0DCD8-6A40-42C5-8459-00F6F085A8C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -27,6 +29,10 @@ Global
{135C846B-59EC-4803-B07C-8991C60C57D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{135C846B-59EC-4803-B07C-8991C60C57D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{135C846B-59EC-4803-B07C-8991C60C57D6}.Release|Any CPU.Build.0 = Release|Any CPU
{25C0DCD8-6A40-42C5-8459-00F6F085A8C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{25C0DCD8-6A40-42C5-8459-00F6F085A8C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25C0DCD8-6A40-42C5-8459-00F6F085A8C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25C0DCD8-6A40-42C5-8459-00F6F085A8C6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Folder Include="BindingModels\" />
<Folder Include="SearchModels\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,22 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class ChequeItemViewModel
{
public int CheuqueId { get; set; }
public int DishId { get; set; }
[DisplayName("Название блюда")]
public string DishName { get; set; } = string.Empty;
public int CookId { get; set; }
[DisplayName("Повар")]
public string CookFio { get; set; } = string.Empty;
[DisplayName("Количество")]
public int Count { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class ChequeViewModel
{
public int Id { get; set; }
public int? CustomerId { get; set; }
[DisplayName("Покупатель")]
public string? CustomerFio { get; set; } = string.Empty;
public Dictionary<int, ChequeItemViewModel> ChequeItems { get; set; } = new();
[DisplayName("Дата заказа")]
public DateTime OrderDate { get; set; }
[DisplayName("Сумма заказа")]
public double TotalSum { get; set; }
public int? PromotionId { get; set; }
[DisplayName("Скидка")]
public float? Discount { get; set; }
}
}

View File

@ -0,0 +1,15 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class CookViewModel
{
public int Id { get; set; }
[DisplayName("Инициалы повара")]
public string Fio { get; set; } = string.Empty;
[DisplayName("Дата приема на работу")]
public DateTime EmploymentDate { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class CustomerViewModel
{
public int Id { get; set; }
[DisplayName("Инициалы покупателя")]
public string Fio { get; set; } = string.Empty;
[DisplayName("Дата рождения")]
public DateTime? BirthdayDate { get; set; }
[DisplayName("Общая сумма всех заказов")]
public double SumOfAllOrders { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class DishIngredientViewModel
{
public int DishId { get; set; }
public int IngredientId { get; set; }
[DisplayName("Наименование ингредиента")]
public string IngredientName { get; set; } = string.Empty;
[DisplayName("Количество")]
public int Count { get; set; }
}
}

View File

@ -0,0 +1,17 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class DishViewModel
{
public int Id { get; set; }
[DisplayName("Название блюда")]
public string DishName { get; set; } = string.Empty;
[DisplayName("Категория")]
public string Category { get; set; } = string.Empty;
public Dictionary<int, DishIngredientViewModel> Ingredients { get; set; } = new();
}
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class IngredientViewModel
{
public int Id { get; set; }
[DisplayName("Наименование ингредиента")]
public string IngredientName { get; set; } = string.Empty;
[DisplayName("Единицы измерения")]
public string Unit { get; set; } = string.Empty;
[DisplayName("Стоимость за единицу")]
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System.ComponentModel;
namespace SushiBarContracts.ViewModels
{
public class PromotionViewModel
{
public int Id { get; set; }
[DisplayName("Название акции")]
public string PromotionName { get; set; } = string.Empty;
[DisplayName("Размер скидки")]
public float Discount { get; set; }
[DisplayName("Минимальная сумма для применения")]
public double TriggeringSum { get; set; }
}
}

View File

@ -0,0 +1,320 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SushiBarDatabaseImplement;
#nullable disable
namespace SushiBarDatabaseImplement.Migrations
{
[DbContext(typeof(SushiBarDatabase))]
[Migration("20240515165005_Initial")]
partial class Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.19")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cheque", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CustomerId")
.HasColumnType("integer");
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp without time zone");
b.Property<int?>("PromotionId")
.HasColumnType("integer");
b.Property<double>("TotalSum")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("PromotionId");
b.ToTable("Cheques");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.ChequeItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ChequeId")
.HasColumnType("integer");
b.Property<int>("CookId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("DishId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ChequeId");
b.HasIndex("CookId");
b.HasIndex("DishId");
b.ToTable("ChequeItems");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cook", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("EmploymentDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("Fio")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Cooks");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("BirthdayDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("Fio")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SumOfAllOrders")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Dish", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Category")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DishName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Dishes");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.DishIngredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("DishId")
.HasColumnType("integer");
b.Property<int>("IngredientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DishId");
b.HasIndex("IngredientId");
b.ToTable("DishIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<string>("IngredientName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Unit")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Ingredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Promotion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<float>("Discount")
.HasColumnType("real");
b.Property<string>("PromotionName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("TriggeringSum")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Promotions");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cheque", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Customer", "Customer")
.WithMany("Cheques")
.HasForeignKey("CustomerId");
b.HasOne("SushiBarDatabaseImplement.Models.Promotion", "Promotion")
.WithMany("Cheques")
.HasForeignKey("PromotionId");
b.Navigation("Customer");
b.Navigation("Promotion");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.ChequeItem", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Cheque", "Cheque")
.WithMany("ChequeItems")
.HasForeignKey("ChequeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Cook", "Cook")
.WithMany("ChequeItems")
.HasForeignKey("CookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Dish", "Dish")
.WithMany("ChequeItems")
.HasForeignKey("DishId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cheque");
b.Navigation("Cook");
b.Navigation("Dish");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.DishIngredient", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Dish", "Dish")
.WithMany("DishIngredients")
.HasForeignKey("DishId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Ingredient", "Ingredient")
.WithMany("DishIngredients")
.HasForeignKey("IngredientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dish");
b.Navigation("Ingredient");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cheque", b =>
{
b.Navigation("ChequeItems");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cook", b =>
{
b.Navigation("ChequeItems");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Customer", b =>
{
b.Navigation("Cheques");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Dish", b =>
{
b.Navigation("ChequeItems");
b.Navigation("DishIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
{
b.Navigation("DishIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Promotion", b =>
{
b.Navigation("Cheques");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,239 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace SushiBarDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Cooks",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Fio = table.Column<string>(type: "text", nullable: false),
EmploymentDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cooks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Customers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Fio = table.Column<string>(type: "text", nullable: false),
BirthdayDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
SumOfAllOrders = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Customers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Dishes",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DishName = table.Column<string>(type: "text", nullable: false),
Category = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Dishes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Ingredients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
IngredientName = table.Column<string>(type: "text", nullable: false),
Unit = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Ingredients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Promotions",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PromotionName = table.Column<string>(type: "text", nullable: false),
Discount = table.Column<float>(type: "real", nullable: false),
TriggeringSum = table.Column<double>(type: "double precision", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Promotions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DishIngredients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DishId = table.Column<int>(type: "integer", nullable: false),
IngredientId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DishIngredients", x => x.Id);
table.ForeignKey(
name: "FK_DishIngredients_Dishes_DishId",
column: x => x.DishId,
principalTable: "Dishes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_DishIngredients_Ingredients_IngredientId",
column: x => x.IngredientId,
principalTable: "Ingredients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Cheques",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CustomerId = table.Column<int>(type: "integer", nullable: true),
OrderDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
TotalSum = table.Column<double>(type: "double precision", nullable: false),
PromotionId = table.Column<int>(type: "integer", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cheques", x => x.Id);
table.ForeignKey(
name: "FK_Cheques_Customers_CustomerId",
column: x => x.CustomerId,
principalTable: "Customers",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Cheques_Promotions_PromotionId",
column: x => x.PromotionId,
principalTable: "Promotions",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "ChequeItems",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ChequeId = table.Column<int>(type: "integer", nullable: false),
DishId = table.Column<int>(type: "integer", nullable: false),
CookId = table.Column<int>(type: "integer", nullable: false),
Count = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChequeItems", x => x.Id);
table.ForeignKey(
name: "FK_ChequeItems_Cheques_ChequeId",
column: x => x.ChequeId,
principalTable: "Cheques",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChequeItems_Cooks_CookId",
column: x => x.CookId,
principalTable: "Cooks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ChequeItems_Dishes_DishId",
column: x => x.DishId,
principalTable: "Dishes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ChequeItems_ChequeId",
table: "ChequeItems",
column: "ChequeId");
migrationBuilder.CreateIndex(
name: "IX_ChequeItems_CookId",
table: "ChequeItems",
column: "CookId");
migrationBuilder.CreateIndex(
name: "IX_ChequeItems_DishId",
table: "ChequeItems",
column: "DishId");
migrationBuilder.CreateIndex(
name: "IX_Cheques_CustomerId",
table: "Cheques",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_Cheques_PromotionId",
table: "Cheques",
column: "PromotionId");
migrationBuilder.CreateIndex(
name: "IX_DishIngredients_DishId",
table: "DishIngredients",
column: "DishId");
migrationBuilder.CreateIndex(
name: "IX_DishIngredients_IngredientId",
table: "DishIngredients",
column: "IngredientId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChequeItems");
migrationBuilder.DropTable(
name: "DishIngredients");
migrationBuilder.DropTable(
name: "Cheques");
migrationBuilder.DropTable(
name: "Cooks");
migrationBuilder.DropTable(
name: "Dishes");
migrationBuilder.DropTable(
name: "Ingredients");
migrationBuilder.DropTable(
name: "Customers");
migrationBuilder.DropTable(
name: "Promotions");
}
}
}

View File

@ -0,0 +1,317 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SushiBarDatabaseImplement;
#nullable disable
namespace SushiBarDatabaseImplement.Migrations
{
[DbContext(typeof(SushiBarDatabase))]
partial class SushiBarDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.19")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cheque", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int?>("CustomerId")
.HasColumnType("integer");
b.Property<DateTime>("OrderDate")
.HasColumnType("timestamp without time zone");
b.Property<int?>("PromotionId")
.HasColumnType("integer");
b.Property<double>("TotalSum")
.HasColumnType("double precision");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("PromotionId");
b.ToTable("Cheques");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.ChequeItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ChequeId")
.HasColumnType("integer");
b.Property<int>("CookId")
.HasColumnType("integer");
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("DishId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ChequeId");
b.HasIndex("CookId");
b.HasIndex("DishId");
b.ToTable("ChequeItems");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cook", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("EmploymentDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("Fio")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Cooks");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<DateTime>("BirthdayDate")
.HasColumnType("timestamp without time zone");
b.Property<string>("Fio")
.IsRequired()
.HasColumnType("text");
b.Property<double>("SumOfAllOrders")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Dish", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Category")
.IsRequired()
.HasColumnType("text");
b.Property<string>("DishName")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Dishes");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.DishIngredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("integer");
b.Property<int>("DishId")
.HasColumnType("integer");
b.Property<int>("IngredientId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("DishId");
b.HasIndex("IngredientId");
b.ToTable("DishIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<string>("IngredientName")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Unit")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Ingredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Promotion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<float>("Discount")
.HasColumnType("real");
b.Property<string>("PromotionName")
.IsRequired()
.HasColumnType("text");
b.Property<double>("TriggeringSum")
.HasColumnType("double precision");
b.HasKey("Id");
b.ToTable("Promotions");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cheque", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Customer", "Customer")
.WithMany("Cheques")
.HasForeignKey("CustomerId");
b.HasOne("SushiBarDatabaseImplement.Models.Promotion", "Promotion")
.WithMany("Cheques")
.HasForeignKey("PromotionId");
b.Navigation("Customer");
b.Navigation("Promotion");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.ChequeItem", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Cheque", "Cheque")
.WithMany("ChequeItems")
.HasForeignKey("ChequeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Cook", "Cook")
.WithMany("ChequeItems")
.HasForeignKey("CookId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Dish", "Dish")
.WithMany("ChequeItems")
.HasForeignKey("DishId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Cheque");
b.Navigation("Cook");
b.Navigation("Dish");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.DishIngredient", b =>
{
b.HasOne("SushiBarDatabaseImplement.Models.Dish", "Dish")
.WithMany("DishIngredients")
.HasForeignKey("DishId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Ingredient", "Ingredient")
.WithMany("DishIngredients")
.HasForeignKey("IngredientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dish");
b.Navigation("Ingredient");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cheque", b =>
{
b.Navigation("ChequeItems");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Cook", b =>
{
b.Navigation("ChequeItems");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Customer", b =>
{
b.Navigation("Cheques");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Dish", b =>
{
b.Navigation("ChequeItems");
b.Navigation("DishIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Ingredient", b =>
{
b.Navigation("DishIngredients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Promotion", b =>
{
b.Navigation("Cheques");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -22,7 +22,7 @@ namespace SushiBarDatabaseImplement.Models
public virtual Promotion? Promotion { get; set; }
[ForeignKey("Cheque")]
public List<ChequeItem> ChequeItems { get; set; } = new();
[ForeignKey("ChequeId")]
public virtual List<ChequeItem> ChequeItems { get; set; } = new();
}
}

View File

@ -15,6 +15,6 @@ namespace SushiBarDatabaseImplement.Models
public DateTime EmploymentDate { get; set; }
[ForeignKey("CookId")]
public List<ChequeItem> ChequeItems { get; set; } = new();
public virtual List<ChequeItem> ChequeItems { get; set; } = new();
}
}

View File

@ -18,6 +18,6 @@ namespace SushiBarDatabaseImplement.Models
public double SumOfAllOrders { get; set; }
[ForeignKey("CustomerId")]
public List<Cheque> Cheques { get; set; } = new();
public virtual List<Cheque> Cheques { get; set; } = new();
}
}

View File

@ -18,6 +18,6 @@ namespace SushiBarDatabaseImplement.Models
public virtual List<DishIngredient> DishIngredients { get; set; } = new();
[ForeignKey("DishId")]
public List<ChequeItem> ChequeItems { get; set; } = new();
public virtual List<ChequeItem> ChequeItems { get; set; } = new();
}
}

View File

@ -18,6 +18,6 @@ namespace SushiBarDatabaseImplement.Models
public double TriggeringSum { get; set; }
[ForeignKey("PromotionId")]
public List<Cheque> Cheques { get; set; } = new();
public virtual List<Cheque> Cheques { get; set; } = new();
}
}

View File

@ -0,0 +1,7 @@
namespace SushiBarDatabaseImplement.Storages
{
public class IngredientStorage
{
public List<>
}
}

View File

@ -12,7 +12,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql" Version="8.0.3" />
<PackageReference Include="Npgsql" Version="7.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.18" />
</ItemGroup>

View File

@ -8,4 +8,15 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.19">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SushiBarDatabaseImplement\SushiBarDatabaseImplement.csproj" />
</ItemGroup>
</Project>