diff --git a/Pizzeria/Pizzeria/Pizzeria.csproj b/Pizzeria/Pizzeria/Pizzeria.csproj
index 50dc696..f5027e2 100644
--- a/Pizzeria/Pizzeria/Pizzeria.csproj
+++ b/Pizzeria/Pizzeria/Pizzeria.csproj
@@ -22,7 +22,6 @@
-
diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.Designer.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.Designer.cs
new file mode 100644
index 0000000..7301176
--- /dev/null
+++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.Designer.cs
@@ -0,0 +1,248 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+using PizzeriaDatabaseImplement;
+
+#nullable disable
+
+namespace PizzeriaDatabaseImplement.Migrations
+{
+ [DbContext(typeof(PizzeriaDatabase))]
+ [Migration("20230423174224_AddShop")]
+ partial class AddShop
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "7.0.3")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Component", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Cost")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.ToTable("Components");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("DateCreate")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DateImplement")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("PizzaId")
+ .HasColumnType("integer");
+
+ b.Property("Status")
+ .HasColumnType("integer");
+
+ b.Property("Sum")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PizzaId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Pizza", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("PizzaName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Price")
+ .HasColumnType("double precision");
+
+ b.HasKey("Id");
+
+ b.ToTable("Pizzas");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.PizzaComponent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ComponentId")
+ .HasColumnType("integer");
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("PizzaId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ComponentId");
+
+ b.HasIndex("PizzaId");
+
+ b.ToTable("PizzaComponents");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Shop", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Addres")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Capacity")
+ .HasColumnType("integer");
+
+ b.Property("OpenTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ShopName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Shops");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.ShopPizza", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("PizzaId")
+ .HasColumnType("integer");
+
+ b.Property("ShopId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PizzaId");
+
+ b.HasIndex("ShopId");
+
+ b.ToTable("ShopPizzas");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Order", b =>
+ {
+ b.HasOne("PizzeriaDatabaseImplement.models.Pizza", "Pizza")
+ .WithMany("Orders")
+ .HasForeignKey("PizzaId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Pizza");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.PizzaComponent", b =>
+ {
+ b.HasOne("PizzeriaDatabaseImplement.models.Component", "Component")
+ .WithMany("PizzaComponents")
+ .HasForeignKey("ComponentId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PizzeriaDatabaseImplement.models.Pizza", "Pizza")
+ .WithMany("Components")
+ .HasForeignKey("PizzaId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Component");
+
+ b.Navigation("Pizza");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.ShopPizza", b =>
+ {
+ b.HasOne("PizzeriaDatabaseImplement.models.Pizza", "Pizza")
+ .WithMany()
+ .HasForeignKey("PizzaId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PizzeriaDatabaseImplement.models.Shop", "Shop")
+ .WithMany("Pizzas")
+ .HasForeignKey("ShopId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Pizza");
+
+ b.Navigation("Shop");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Component", b =>
+ {
+ b.Navigation("PizzaComponents");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Pizza", b =>
+ {
+ b.Navigation("Components");
+
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Shop", b =>
+ {
+ b.Navigation("Pizzas");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.cs
new file mode 100644
index 0000000..2480d5e
--- /dev/null
+++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.cs
@@ -0,0 +1,79 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace PizzeriaDatabaseImplement.Migrations
+{
+ ///
+ public partial class AddShop : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Shops",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ ShopName = table.Column(type: "text", nullable: false),
+ Addres = table.Column(type: "text", nullable: false),
+ OpenTime = table.Column(type: "timestamp with time zone", nullable: false),
+ Capacity = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Shops", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ShopPizzas",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ PizzaId = table.Column(type: "integer", nullable: false),
+ ShopId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ShopPizzas", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ShopPizzas_Pizzas_PizzaId",
+ column: x => x.PizzaId,
+ principalTable: "Pizzas",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_ShopPizzas_Shops_ShopId",
+ column: x => x.ShopId,
+ principalTable: "Shops",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ShopPizzas_PizzaId",
+ table: "ShopPizzas",
+ column: "PizzaId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ShopPizzas_ShopId",
+ table: "ShopPizzas",
+ column: "ShopId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "ShopPizzas");
+
+ migrationBuilder.DropTable(
+ name: "Shops");
+ }
+ }
+}
diff --git a/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs b/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs
index ae2eb4b..2375de3 100644
--- a/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs
+++ b/Pizzeria/PizzeriaDatabaseImplement/Migrations/PizzeriaDatabaseModelSnapshot.cs
@@ -121,6 +121,59 @@ namespace PizzeriaDatabaseImplement.Migrations
b.ToTable("PizzaComponents");
});
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Shop", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Addres")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.Property("Capacity")
+ .HasColumnType("integer");
+
+ b.Property("OpenTime")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("ShopName")
+ .IsRequired()
+ .HasColumnType("text");
+
+ b.HasKey("Id");
+
+ b.ToTable("Shops");
+ });
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.ShopPizza", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("integer");
+
+ b.Property("PizzaId")
+ .HasColumnType("integer");
+
+ b.Property("ShopId")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PizzaId");
+
+ b.HasIndex("ShopId");
+
+ b.ToTable("ShopPizzas");
+ });
+
modelBuilder.Entity("PizzeriaDatabaseImplement.models.Order", b =>
{
b.HasOne("PizzeriaDatabaseImplement.models.Pizza", "Pizza")
@@ -151,6 +204,25 @@ namespace PizzeriaDatabaseImplement.Migrations
b.Navigation("Pizza");
});
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.ShopPizza", b =>
+ {
+ b.HasOne("PizzeriaDatabaseImplement.models.Pizza", "Pizza")
+ .WithMany()
+ .HasForeignKey("PizzaId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("PizzeriaDatabaseImplement.models.Shop", "Shop")
+ .WithMany("Pizzas")
+ .HasForeignKey("ShopId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Pizza");
+
+ b.Navigation("Shop");
+ });
+
modelBuilder.Entity("PizzeriaDatabaseImplement.models.Component", b =>
{
b.Navigation("PizzaComponents");
@@ -162,6 +234,11 @@ namespace PizzeriaDatabaseImplement.Migrations
b.Navigation("Orders");
});
+
+ modelBuilder.Entity("PizzeriaDatabaseImplement.models.Shop", b =>
+ {
+ b.Navigation("Pizzas");
+ });
#pragma warning restore 612, 618
}
}
diff --git a/Pizzeria/PizzeriaDatabaseImplement/models/Shop.cs b/Pizzeria/PizzeriaDatabaseImplement/models/Shop.cs
index e67e78d..4d079ef 100644
--- a/Pizzeria/PizzeriaDatabaseImplement/models/Shop.cs
+++ b/Pizzeria/PizzeriaDatabaseImplement/models/Shop.cs
@@ -3,13 +3,11 @@ using PizzeriaContracts.ViewModels;
using PizzeriaDataModels;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-using System.Diagnostics;
namespace PizzeriaDatabaseImplement.models
{
public class Shop : IShopModel
{
- [Required]
public int Id { get; set; }
[Required]
public string ShopName { get; set; } = string.Empty;
@@ -43,8 +41,7 @@ namespace PizzeriaDatabaseImplement.models
Addres = model.Addres,
OpenTime = model.OpenTime,
Capacity = model.Capacity,
- Pizzas = model.ShopPizzas.Select(x => new
- ShopPizza
+ Pizzas = model.ShopPizzas.Select(x => new ShopPizza
{
Pizza = context.Pizzas.First(y => y.Id == x.Key),
Count = x.Value.Item2
diff --git a/Pizzeria/PizzeriaListImplement/Implements/ShopStorage.cs b/Pizzeria/PizzeriaListImplement/Implements/ShopStorage.cs
index 137a7af..882deb6 100644
--- a/Pizzeria/PizzeriaListImplement/Implements/ShopStorage.cs
+++ b/Pizzeria/PizzeriaListImplement/Implements/ShopStorage.cs
@@ -2,6 +2,7 @@
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.StoragesContracts;
using PizzeriaContracts.ViewModels;
+using PizzeriaDataModels;
using PizzeriaListImplement.Models;
namespace PizzeriaListImplement.Implements
@@ -112,5 +113,10 @@ namespace PizzeriaListImplement.Implements
return null;
}
+
+ public bool TrySellPizza(IPizzaModel pizza, int count)
+ {
+ throw new NotImplementedException();
+ }
}
}