RecipeModels
This commit is contained in:
parent
184fbb3728
commit
108598ef98
backend/API
@ -1,4 +1,5 @@
|
||||
using API.Models.UserModels;
|
||||
using API.Models.RecipeModels;
|
||||
using API.Models.UserModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.DBAccess
|
||||
@ -7,6 +8,10 @@ namespace API.DBAccess
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
public DbSet<PrefereredRecipes> PrefereredRecipes { get; set; }
|
||||
|
||||
public DbSet<Recipe> Recipes { get; set; }
|
||||
|
||||
public DBContext(DbContextOptions<DBContext> options) : base(options) { }
|
||||
}
|
||||
}
|
||||
|
165
backend/API/Migrations/20250428070005_RecipeModelAdded.Designer.cs
generated
Normal file
165
backend/API/Migrations/20250428070005_RecipeModelAdded.Designer.cs
generated
Normal file
@ -0,0 +1,165 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using API.DBAccess;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Migrations
|
||||
{
|
||||
[DbContext(typeof(DBContext))]
|
||||
[Migration("20250428070005_RecipeModelAdded")]
|
||||
partial class RecipeModelAdded
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Element")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("RecipeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Unit")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RecipeId");
|
||||
|
||||
b.ToTable("Ingredient");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.PrefereredRecipes", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PrefereredRecipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Directions")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("PrefereredRecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PrefereredRecipesId");
|
||||
|
||||
b.ToTable("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.UserModels.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("PrefereredRecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RefreshToken")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<DateTime>("RefreshTokenExpireAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Salt")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("UserName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PrefereredRecipesId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
||||
{
|
||||
b.HasOne("API.Models.RecipeModels.Recipe", null)
|
||||
.WithMany("Ingredients")
|
||||
.HasForeignKey("RecipeId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||
{
|
||||
b.HasOne("API.Models.RecipeModels.PrefereredRecipes", null)
|
||||
.WithMany("Recipes")
|
||||
.HasForeignKey("PrefereredRecipesId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.UserModels.User", b =>
|
||||
{
|
||||
b.HasOne("API.Models.RecipeModels.PrefereredRecipes", "PrefereredRecipes")
|
||||
.WithMany()
|
||||
.HasForeignKey("PrefereredRecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PrefereredRecipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.PrefereredRecipes", b =>
|
||||
{
|
||||
b.Navigation("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||
{
|
||||
b.Navigation("Ingredients");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
127
backend/API/Migrations/20250428070005_RecipeModelAdded.cs
Normal file
127
backend/API/Migrations/20250428070005_RecipeModelAdded.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using MySql.EntityFrameworkCore.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RecipeModelAdded : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PrefereredRecipesId",
|
||||
table: "Users",
|
||||
type: "int",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PrefereredRecipes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PrefereredRecipes", x => x.Id);
|
||||
})
|
||||
.Annotation("MySQL:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Recipes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false),
|
||||
Directions = table.Column<string>(type: "longtext", nullable: false),
|
||||
PrefereredRecipesId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Recipes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Recipes_PrefereredRecipes_PrefereredRecipesId",
|
||||
column: x => x.PrefereredRecipesId,
|
||||
principalTable: "PrefereredRecipes",
|
||||
principalColumn: "Id");
|
||||
})
|
||||
.Annotation("MySQL:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Ingredient",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
|
||||
Amount = table.Column<int>(type: "int", nullable: false),
|
||||
Unit = table.Column<string>(type: "longtext", nullable: false),
|
||||
Element = table.Column<string>(type: "longtext", nullable: false),
|
||||
RecipeId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Ingredient", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Ingredient_Recipes_RecipeId",
|
||||
column: x => x.RecipeId,
|
||||
principalTable: "Recipes",
|
||||
principalColumn: "Id");
|
||||
})
|
||||
.Annotation("MySQL:Charset", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_PrefereredRecipesId",
|
||||
table: "Users",
|
||||
column: "PrefereredRecipesId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Ingredient_RecipeId",
|
||||
table: "Ingredient",
|
||||
column: "RecipeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Recipes_PrefereredRecipesId",
|
||||
table: "Recipes",
|
||||
column: "PrefereredRecipesId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Users_PrefereredRecipes_PrefereredRecipesId",
|
||||
table: "Users",
|
||||
column: "PrefereredRecipesId",
|
||||
principalTable: "PrefereredRecipes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Users_PrefereredRecipes_PrefereredRecipesId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Ingredient");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Recipes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PrefereredRecipes");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Users_PrefereredRecipesId",
|
||||
table: "Users");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PrefereredRecipesId",
|
||||
table: "Users");
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,72 @@ namespace API.Migrations
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Amount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Element")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("RecipeId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Unit")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RecipeId");
|
||||
|
||||
b.ToTable("Ingredient");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.PrefereredRecipes", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PrefereredRecipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Directions")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("PrefereredRecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PrefereredRecipesId");
|
||||
|
||||
b.ToTable("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.UserModels.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -33,6 +99,9 @@ namespace API.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("PrefereredRecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("RefreshToken")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
@ -48,8 +117,45 @@ namespace API.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PrefereredRecipesId");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
||||
{
|
||||
b.HasOne("API.Models.RecipeModels.Recipe", null)
|
||||
.WithMany("Ingredients")
|
||||
.HasForeignKey("RecipeId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||
{
|
||||
b.HasOne("API.Models.RecipeModels.PrefereredRecipes", null)
|
||||
.WithMany("Recipes")
|
||||
.HasForeignKey("PrefereredRecipesId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.UserModels.User", b =>
|
||||
{
|
||||
b.HasOne("API.Models.RecipeModels.PrefereredRecipes", "PrefereredRecipes")
|
||||
.WithMany()
|
||||
.HasForeignKey("PrefereredRecipesId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("PrefereredRecipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.PrefereredRecipes", b =>
|
||||
{
|
||||
b.Navigation("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||
{
|
||||
b.Navigation("Ingredients");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
13
backend/API/Models/RecipeModels/Ingredient.cs
Normal file
13
backend/API/Models/RecipeModels/Ingredient.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace API.Models.RecipeModels
|
||||
{
|
||||
public class Ingredient
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int Amount { get; set; }
|
||||
|
||||
public string Unit { get; set; }
|
||||
|
||||
public string Element { get; set; }
|
||||
}
|
||||
}
|
9
backend/API/Models/RecipeModels/PrefereredRecipes.cs
Normal file
9
backend/API/Models/RecipeModels/PrefereredRecipes.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace API.Models.RecipeModels
|
||||
{
|
||||
public class PrefereredRecipes
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public List<Recipe> Recipes { get; set; }
|
||||
}
|
||||
}
|
15
backend/API/Models/RecipeModels/Recipe.cs
Normal file
15
backend/API/Models/RecipeModels/Recipe.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace API.Models.RecipeModels
|
||||
{
|
||||
public class Recipe
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Directions { get; set; }
|
||||
|
||||
public List<Ingredient> Ingredients { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
namespace API.Models.UserModels
|
||||
using API.Models.RecipeModels;
|
||||
|
||||
namespace API.Models.UserModels
|
||||
{
|
||||
public class User
|
||||
{
|
||||
@ -15,5 +17,7 @@
|
||||
public string? RefreshToken { get; set; }
|
||||
|
||||
public DateTime RefreshTokenExpireAt { get; set; }
|
||||
|
||||
public PrefereredRecipes PrefereredRecipes { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user