lab3 full
This commit is contained in:
parent
205cc3df40
commit
f80eb3c08c
@ -22,7 +22,6 @@
|
||||
<ProjectReference Include="..\PizzeriaBusinessLogic\PizzeriaBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\PizzeriaDatabaseImplement\PizzeriaDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\PizzeriaDataModels\PizzeriaDataModels.csproj" />
|
||||
<ProjectReference Include="..\PizzeriaShopFileImplement\PizzeriaFileImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
248
Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.Designer.cs
generated
Normal file
248
Pizzeria/PizzeriaDatabaseImplement/Migrations/20230423174224_AddShop.Designer.cs
generated
Normal file
@ -0,0 +1,248 @@
|
||||
// <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 PizzeriaDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PizzeriaDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(PizzeriaDatabase))]
|
||||
[Migration("20230423174224_AddShop")]
|
||||
partial class AddShop
|
||||
{
|
||||
/// <inheritdoc />
|
||||
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<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PizzeriaDatabaseImplement.models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<int>("PizzaId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PizzaId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PizzeriaDatabaseImplement.models.Pizza", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("PizzaName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Pizzas");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PizzeriaDatabaseImplement.models.PizzaComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PizzaId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("PizzaId");
|
||||
|
||||
b.ToTable("PizzaComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PizzeriaDatabaseImplement.models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Addres")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("OpenTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PizzeriaDatabaseImplement.models.ShopPizza", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PizzaId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PizzeriaDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddShop : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ShopName = table.Column<string>(type: "text", nullable: false),
|
||||
Addres = table.Column<string>(type: "text", nullable: false),
|
||||
OpenTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Capacity = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopPizzas",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
PizzaId = table.Column<int>(type: "integer", nullable: false),
|
||||
ShopId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(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");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopPizzas");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
}
|
||||
}
|
||||
}
|
@ -121,6 +121,59 @@ namespace PizzeriaDatabaseImplement.Migrations
|
||||
b.ToTable("PizzaComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PizzeriaDatabaseImplement.models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Addres")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("Capacity")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("OpenTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PizzeriaDatabaseImplement.models.ShopPizza", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("PizzaId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user