fix models in DatabaseImplement
This commit is contained in:
parent
2726b6e623
commit
7fea674731
@ -21,8 +21,4 @@
|
|||||||
<ProjectReference Include="..\FlowerShopDataModels\FlowerShopDataModels.csproj" />
|
<ProjectReference Include="..\FlowerShopDataModels\FlowerShopDataModels.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Migrations\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace FlowerShopDatabaseImplement.Migrations
|
namespace FlowerShopDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(FlowerShopDatabase))]
|
[DbContext(typeof(FlowerShopDatabase))]
|
||||||
[Migration("20240516204422_InitCreate")]
|
[Migration("20240517110214_InitCreate")]
|
||||||
partial class InitCreate
|
partial class InitCreate
|
||||||
{
|
{
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
@ -130,10 +130,10 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
b.Property<DateTime>("DateCreate")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int>("FlowerId")
|
b.Property<int>("FlowerId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
@ -146,6 +146,8 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
b.HasIndex("FlowerId");
|
b.HasIndex("FlowerId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -164,7 +166,7 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("DateOpening")
|
b.Property<DateTime>("DateOpening")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int>("MaximumFlowers")
|
b.Property<int>("MaximumFlowers")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
@ -225,11 +227,21 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("FlowerShopDatabaseImplement.Models.Flower", null)
|
b.HasOne("FlowerShopDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FlowerShopDatabaseImplement.Models.Flower", "Flower")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("FlowerId")
|
.HasForeignKey("FlowerId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Flower");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
||||||
@ -251,6 +263,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.Navigation("Shop");
|
b.Navigation("Shop");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Component", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Component", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("FlowerComponents");
|
b.Navigation("FlowerComponents");
|
@ -61,7 +61,7 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
ShopName = table.Column<string>(type: "text", nullable: false),
|
ShopName = table.Column<string>(type: "text", nullable: false),
|
||||||
Address = table.Column<string>(type: "text", nullable: false),
|
Address = table.Column<string>(type: "text", nullable: false),
|
||||||
DateOpening = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
DateOpening = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||||
MaximumFlowers = table.Column<int>(type: "integer", nullable: false)
|
MaximumFlowers = table.Column<int>(type: "integer", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
@ -107,12 +107,18 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
Count = table.Column<int>(type: "integer", nullable: false),
|
Count = table.Column<int>(type: "integer", nullable: false),
|
||||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||||
Status = table.Column<int>(type: "integer", nullable: false),
|
Status = table.Column<int>(type: "integer", nullable: false),
|
||||||
DateCreate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||||
DateImplement = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
DateImplement = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Clients_ClientId",
|
||||||
|
column: x => x.ClientId,
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Orders_Flowers_FlowerId",
|
name: "FK_Orders_Flowers_FlowerId",
|
||||||
column: x => x.FlowerId,
|
column: x => x.FlowerId,
|
||||||
@ -158,6 +164,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
table: "FlowerComponents",
|
table: "FlowerComponents",
|
||||||
column: "FlowerId");
|
column: "FlowerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ClientId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ClientId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Orders_FlowerId",
|
name: "IX_Orders_FlowerId",
|
||||||
table: "Orders",
|
table: "Orders",
|
||||||
@ -176,9 +187,6 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Clients");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "FlowerComponents");
|
name: "FlowerComponents");
|
||||||
|
|
||||||
@ -191,6 +199,9 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Components");
|
name: "Components");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Clients");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Flowers");
|
name: "Flowers");
|
||||||
|
|
@ -128,10 +128,10 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<DateTime>("DateCreate")
|
b.Property<DateTime>("DateCreate")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int>("FlowerId")
|
b.Property<int>("FlowerId")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
@ -144,6 +144,8 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
b.HasIndex("FlowerId");
|
b.HasIndex("FlowerId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -162,7 +164,7 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<DateTime>("DateOpening")
|
b.Property<DateTime>("DateOpening")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
b.Property<int>("MaximumFlowers")
|
b.Property<int>("MaximumFlowers")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
@ -223,11 +225,21 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("FlowerShopDatabaseImplement.Models.Flower", null)
|
b.HasOne("FlowerShopDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FlowerShopDatabaseImplement.Models.Flower", "Flower")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("FlowerId")
|
.HasForeignKey("FlowerId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Flower");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.ShopFlower", b =>
|
||||||
@ -249,6 +261,11 @@ namespace FlowerShopDatabaseImplement.Migrations
|
|||||||
b.Navigation("Shop");
|
b.Navigation("Shop");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Component", b =>
|
modelBuilder.Entity("FlowerShopDatabaseImplement.Models.Component", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("FlowerComponents");
|
b.Navigation("FlowerComponents");
|
||||||
|
@ -15,6 +15,8 @@ namespace FlowerShopDatabaseImplement.Models
|
|||||||
public string Email { get; private set; } = string.Empty;
|
public string Email { get; private set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public string Password { get; private set; } = string.Empty;
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
public static Client? Create(ClientBindingModel model)
|
public static Client? Create(ClientBindingModel model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
|
@ -9,8 +9,12 @@ namespace FlowerShopDatabaseImplement.Models
|
|||||||
public class Order : IOrderModel
|
public class Order : IOrderModel
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[Required]
|
||||||
public int FlowerId { get; private set; }
|
public int FlowerId { get; private set; }
|
||||||
|
public virtual Flower Flower { get; set; }
|
||||||
|
[Required]
|
||||||
public int ClientId { get; private set; }
|
public int ClientId { get; private set; }
|
||||||
|
public virtual Client Client { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
|
Loading…
Reference in New Issue
Block a user