Compare commits
No commits in common. "f5d580afe705b365bd2bed7afc99d7c1d0bcac65" and "75559daacb621bb5bc4f17d64b33d974aac9d229" have entirely different histories.
f5d580afe7
...
75559daacb
@ -13,7 +13,7 @@ namespace API.BusinessLogic
|
|||||||
_dbAccess = dbAccess;
|
_dbAccess = dbAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> GetRecipes(int userId)
|
public async Task<IActionResult> GetPrefereredRecipes(int userId)
|
||||||
{
|
{
|
||||||
var recipes = await _dbAccess.ReadRecipes(userId);
|
var recipes = await _dbAccess.ReadRecipes(userId);
|
||||||
if (recipes == null || recipes.Count == 0) { return new ConflictObjectResult(new { message = "Could not find any recipes" }); }
|
if (recipes == null || recipes.Count == 0) { return new ConflictObjectResult(new { message = "Could not find any recipes" }); }
|
||||||
@ -30,11 +30,11 @@ namespace API.BusinessLogic
|
|||||||
return new OkObjectResult(recipe);
|
return new OkObjectResult(recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> CreateRecipe(RecipeDTO recipe, int userId)
|
public async Task<IActionResult> CreateRecipe(RecipeDTO recipe, int prefereredRecipesId)
|
||||||
{
|
{
|
||||||
var recipes = await _dbAccess.ReadRecipes(userId);
|
var prefereredRecipes = await _dbAccess.ReadAllRecipe(prefereredRecipesId);
|
||||||
|
|
||||||
foreach (var item in recipes)
|
foreach (var item in prefereredRecipes.Recipes)
|
||||||
{
|
{
|
||||||
if (item.Name == recipe.Name)
|
if (item.Name == recipe.Name)
|
||||||
{
|
{
|
||||||
@ -42,27 +42,21 @@ namespace API.BusinessLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Recipe dish = new Recipe();
|
Recipe recipe1 = new Recipe();
|
||||||
dish.Name = recipe.Name;
|
recipe1.Name = recipe.Name;
|
||||||
dish.Description = recipe.Description;
|
recipe1.Directions = recipe.Directions;
|
||||||
dish.Ingredients = new List<Ingredient>();
|
recipe1.Description = recipe.Description;
|
||||||
dish.Directions = new List<Directions>();
|
recipe1.Ingredients = new List<Ingredient>();
|
||||||
foreach (var item in recipe.Ingredients)
|
foreach (var item in recipe.Ingredients)
|
||||||
{
|
{
|
||||||
Ingredient ingredient = new Ingredient();
|
Ingredient ingredient = new Ingredient();
|
||||||
ingredient.Unit = item.Unit;
|
ingredient.Unit = item.Unit;
|
||||||
ingredient.Name = item.Name;
|
ingredient.Name = item.Name;
|
||||||
ingredient.Amount = item.Amount;
|
ingredient.Amount = item.Amount;
|
||||||
dish.Ingredients.Add(ingredient);
|
recipe1.Ingredients.Add(ingredient);
|
||||||
}
|
|
||||||
foreach (var item in recipe.Directions)
|
|
||||||
{
|
|
||||||
Directions directions = new Directions();
|
|
||||||
directions.Instruktions = item.Instructions;
|
|
||||||
dish.Directions.Add(directions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return await _dbAccess.CreateRecipe(dish, userId);
|
return await _dbAccess.CreateRecipe(recipe1, prefereredRecipesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> EditRecipe(RecipeDTO recipe, int recipeId, int userId)
|
public async Task<IActionResult> EditRecipe(RecipeDTO recipe, int recipeId, int userId)
|
||||||
@ -80,7 +74,7 @@ namespace API.BusinessLogic
|
|||||||
|
|
||||||
dish.Name = recipe.Name;
|
dish.Name = recipe.Name;
|
||||||
dish.Description = recipe.Description;
|
dish.Description = recipe.Description;
|
||||||
dish.Directions = new List<Directions>();
|
dish.Directions = recipe.Directions;
|
||||||
foreach (var item in recipe.Ingredients)
|
foreach (var item in recipe.Ingredients)
|
||||||
{
|
{
|
||||||
Ingredient ingredient = new Ingredient();
|
Ingredient ingredient = new Ingredient();
|
||||||
@ -89,12 +83,6 @@ namespace API.BusinessLogic
|
|||||||
ingredient.Amount = item.Amount;
|
ingredient.Amount = item.Amount;
|
||||||
dish.Ingredients.Add(ingredient);
|
dish.Ingredients.Add(ingredient);
|
||||||
}
|
}
|
||||||
foreach (var item in recipe.Directions)
|
|
||||||
{
|
|
||||||
Directions directions = new Directions();
|
|
||||||
directions.Instruktions = item.Instructions;
|
|
||||||
dish.Directions.Add(directions);
|
|
||||||
}
|
|
||||||
|
|
||||||
return await _dbAccess.UpdateRecipe(dish);
|
return await _dbAccess.UpdateRecipe(dish);
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@ namespace API.Controllers
|
|||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpGet("getall")]
|
[HttpGet("getall")]
|
||||||
public async Task<IActionResult> ReadRecipes()
|
public async Task<IActionResult> ReadPrefereredRecipes()
|
||||||
{
|
{
|
||||||
var claims = HttpContext.User.Claims;
|
var claims = HttpContext.User.Claims;
|
||||||
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
int userId = Convert.ToInt32(userIdString);
|
int userId = Convert.ToInt32(userIdString);
|
||||||
return await _recipeLogic.GetRecipes(userId);
|
return await _recipeLogic.GetPrefereredRecipes(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
@ -35,10 +35,10 @@ namespace API.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[HttpPost("create/{RecipesId}")]
|
[HttpPost("create/{prefereredRecipesId}")]
|
||||||
public async Task<IActionResult> CreateRecipe([FromBody] RecipeDTO recipe, int RecipesId)
|
public async Task<IActionResult> CreateRecipe([FromBody] RecipeDTO recipe, int prefereredRecipesId)
|
||||||
{
|
{
|
||||||
return await _recipeLogic.CreateRecipe(recipe, RecipesId);
|
return await _recipeLogic.CreateRecipe(recipe, prefereredRecipesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
|
@ -9,6 +9,8 @@ namespace API.DBAccess
|
|||||||
{
|
{
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
|
public DbSet<PrefereredRecipes> PrefereredRecipes { get; set; }
|
||||||
|
|
||||||
public DbSet<Recipe> Recipes { get; set; }
|
public DbSet<Recipe> Recipes { get; set; }
|
||||||
|
|
||||||
public DbSet<ShoppingList> ShoppingList { get; set; }
|
public DbSet<ShoppingList> ShoppingList { get; set; }
|
||||||
|
@ -21,14 +21,19 @@ namespace API.DBAccess
|
|||||||
return recipes.Recipes;
|
return recipes.Recipes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<PrefereredRecipes> ReadAllRecipe(int prefereredRecipesId)
|
||||||
|
{
|
||||||
|
return await _context.PrefereredRecipes.Include(p => p.Recipes).FirstOrDefaultAsync(r => r.Id == prefereredRecipesId);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<Recipe> ReadRecipe(int recipeId)
|
public async Task<Recipe> ReadRecipe(int recipeId)
|
||||||
{
|
{
|
||||||
return await _context.Recipes.Include(r => r.Ingredients).FirstOrDefaultAsync(r => r.Id == recipeId);
|
return await _context.Recipes.Include(r => r.Ingredients).FirstOrDefaultAsync(r => r.Id == recipeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> CreateRecipe(Recipe recipe, int userId)
|
public async Task<IActionResult> CreateRecipe(Recipe recipe, int prefereredRecipeId)
|
||||||
{
|
{
|
||||||
var recipes = await _context.Users.Include(p => p.Recipes).FirstOrDefaultAsync(u => u.Id == userId);
|
var recipes = await _context.PrefereredRecipes.Include(p => p.Recipes).FirstOrDefaultAsync(p => p.Id == prefereredRecipeId);
|
||||||
|
|
||||||
recipes.Recipes.Add(recipe);
|
recipes.Recipes.Add(recipe);
|
||||||
|
|
||||||
|
@ -1,200 +0,0 @@
|
|||||||
// <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("20250430110454_MadeAmountAndUnitNullable")]
|
|
||||||
partial class MadeAmountAndUnitNullable
|
|
||||||
{
|
|
||||||
/// <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.Directions", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Instruktions")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("RecipeId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("RecipeId");
|
|
||||||
|
|
||||||
b.ToTable("Directions");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double?>("Amount")
|
|
||||||
.HasColumnType("double");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("RecipeId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Unit")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("RecipeId");
|
|
||||||
|
|
||||||
b.ToTable("Ingredient");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("UserId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("Recipes");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.ShoppingListModels.ShoppingList", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double?>("Amount")
|
|
||||||
.HasColumnType("double");
|
|
||||||
|
|
||||||
b.Property<bool>("Checked")
|
|
||||||
.HasColumnType("tinyint(1)");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<string>("Unit")
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("UserId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("ShoppingList");
|
|
||||||
});
|
|
||||||
|
|
||||||
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<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.ToTable("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Directions", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("API.Models.RecipeModels.Recipe", null)
|
|
||||||
.WithMany("Directions")
|
|
||||||
.HasForeignKey("RecipeId");
|
|
||||||
});
|
|
||||||
|
|
||||||
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.UserModels.User", null)
|
|
||||||
.WithMany("Recipes")
|
|
||||||
.HasForeignKey("UserId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.ShoppingListModels.ShoppingList", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("API.Models.UserModels.User", null)
|
|
||||||
.WithMany("ShoppingList")
|
|
||||||
.HasForeignKey("UserId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Directions");
|
|
||||||
|
|
||||||
b.Navigation("Ingredients");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.UserModels.User", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Recipes");
|
|
||||||
|
|
||||||
b.Navigation("ShoppingList");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,175 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using MySql.EntityFrameworkCore.Metadata;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace API.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class MadeAmountAndUnitNullable : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_Recipes_PrefereredRecipes_PrefereredRecipesId",
|
|
||||||
table: "Recipes");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PrefereredRecipes");
|
|
||||||
|
|
||||||
migrationBuilder.DropIndex(
|
|
||||||
name: "IX_Recipes_PrefereredRecipesId",
|
|
||||||
table: "Recipes");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "Directions",
|
|
||||||
table: "Recipes");
|
|
||||||
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "PrefereredRecipesId",
|
|
||||||
table: "Recipes");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Unit",
|
|
||||||
table: "ShoppingList",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<double>(
|
|
||||||
name: "Amount",
|
|
||||||
table: "ShoppingList",
|
|
||||||
type: "double",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(double),
|
|
||||||
oldType: "double");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Unit",
|
|
||||||
table: "Ingredient",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<double>(
|
|
||||||
name: "Amount",
|
|
||||||
table: "Ingredient",
|
|
||||||
type: "double",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "int");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Directions",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
|
|
||||||
Instruktions = table.Column<string>(type: "longtext", nullable: false),
|
|
||||||
RecipeId = table.Column<int>(type: "int", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Directions", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Directions_Recipes_RecipeId",
|
|
||||||
column: x => x.RecipeId,
|
|
||||||
principalTable: "Recipes",
|
|
||||||
principalColumn: "Id");
|
|
||||||
})
|
|
||||||
.Annotation("MySQL:Charset", "utf8mb4");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Directions_RecipeId",
|
|
||||||
table: "Directions",
|
|
||||||
column: "RecipeId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Directions");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Unit",
|
|
||||||
table: "ShoppingList",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "",
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<double>(
|
|
||||||
name: "Amount",
|
|
||||||
table: "ShoppingList",
|
|
||||||
type: "double",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0.0,
|
|
||||||
oldClrType: typeof(double),
|
|
||||||
oldType: "double",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
|
||||||
name: "Directions",
|
|
||||||
table: "Recipes",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false);
|
|
||||||
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "PrefereredRecipesId",
|
|
||||||
table: "Recipes",
|
|
||||||
type: "int",
|
|
||||||
nullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
|
||||||
name: "Unit",
|
|
||||||
table: "Ingredient",
|
|
||||||
type: "longtext",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: "",
|
|
||||||
oldClrType: typeof(string),
|
|
||||||
oldType: "longtext",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "Amount",
|
|
||||||
table: "Ingredient",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(double),
|
|
||||||
oldType: "double",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
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.CreateIndex(
|
|
||||||
name: "IX_Recipes_PrefereredRecipesId",
|
|
||||||
table: "Recipes",
|
|
||||||
column: "PrefereredRecipesId");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_Recipes_PrefereredRecipes_PrefereredRecipesId",
|
|
||||||
table: "Recipes",
|
|
||||||
column: "PrefereredRecipesId",
|
|
||||||
principalTable: "PrefereredRecipes",
|
|
||||||
principalColumn: "Id");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,34 +19,14 @@ namespace API.Migrations
|
|||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Directions", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Instruktions")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("longtext");
|
|
||||||
|
|
||||||
b.Property<int?>("RecipeId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("RecipeId");
|
|
||||||
|
|
||||||
b.ToTable("Directions");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<double?>("Amount")
|
b.Property<int>("Amount")
|
||||||
.HasColumnType("double");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
@ -56,6 +36,7 @@ namespace API.Migrations
|
|||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<string>("Unit")
|
b.Property<string>("Unit")
|
||||||
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
@ -65,6 +46,17 @@ namespace API.Migrations
|
|||||||
b.ToTable("Ingredient");
|
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 =>
|
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -75,15 +67,24 @@ namespace API.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Directions")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("PrefereredRecipesId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int?>("UserId")
|
b.Property<int?>("UserId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PrefereredRecipesId");
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
b.ToTable("Recipes");
|
b.ToTable("Recipes");
|
||||||
@ -95,7 +96,7 @@ namespace API.Migrations
|
|||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<double?>("Amount")
|
b.Property<double>("Amount")
|
||||||
.HasColumnType("double");
|
.HasColumnType("double");
|
||||||
|
|
||||||
b.Property<bool>("Checked")
|
b.Property<bool>("Checked")
|
||||||
@ -106,6 +107,7 @@ namespace API.Migrations
|
|||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<string>("Unit")
|
b.Property<string>("Unit")
|
||||||
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<int?>("UserId")
|
b.Property<int?>("UserId")
|
||||||
@ -150,13 +152,6 @@ namespace API.Migrations
|
|||||||
b.ToTable("Users");
|
b.ToTable("Users");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Directions", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("API.Models.RecipeModels.Recipe", null)
|
|
||||||
.WithMany("Directions")
|
|
||||||
.HasForeignKey("RecipeId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
modelBuilder.Entity("API.Models.RecipeModels.Ingredient", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("API.Models.RecipeModels.Recipe", null)
|
b.HasOne("API.Models.RecipeModels.Recipe", null)
|
||||||
@ -166,6 +161,10 @@ namespace API.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||||
{
|
{
|
||||||
|
b.HasOne("API.Models.RecipeModels.PrefereredRecipes", null)
|
||||||
|
.WithMany("Recipes")
|
||||||
|
.HasForeignKey("PrefereredRecipesId");
|
||||||
|
|
||||||
b.HasOne("API.Models.UserModels.User", null)
|
b.HasOne("API.Models.UserModels.User", null)
|
||||||
.WithMany("Recipes")
|
.WithMany("Recipes")
|
||||||
.HasForeignKey("UserId");
|
.HasForeignKey("UserId");
|
||||||
@ -178,10 +177,13 @@ namespace API.Migrations
|
|||||||
.HasForeignKey("UserId");
|
.HasForeignKey("UserId");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("API.Models.RecipeModels.PrefereredRecipes", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Recipes");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Directions");
|
|
||||||
|
|
||||||
b.Navigation("Ingredients");
|
b.Navigation("Ingredients");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
namespace API.Models.RecipeModels
|
|
||||||
{
|
|
||||||
public class DirectionsDTO
|
|
||||||
{
|
|
||||||
public string Instructions { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,9 +4,9 @@
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public double? Amount { get; set; }
|
public int Amount { get; set; }
|
||||||
|
|
||||||
public string? Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
{
|
{
|
||||||
public class IngredientDTO
|
public class IngredientDTO
|
||||||
{
|
{
|
||||||
public double? Amount { get; set; }
|
public int Amount { get; set; }
|
||||||
|
|
||||||
public string? Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
namespace API.Models.RecipeModels
|
namespace API.Models.RecipeModels
|
||||||
{
|
{
|
||||||
public class Directions
|
public class PrefereredRecipes
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string Instruktions { get; set; }
|
public List<Recipe> Recipes { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
7
backend/API/Models/RecipeModels/PrefereredRecipesDTO.cs
Normal file
7
backend/API/Models/RecipeModels/PrefereredRecipesDTO.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace API.Models.RecipeModels
|
||||||
|
{
|
||||||
|
public class PrefereredRecipesDTO
|
||||||
|
{
|
||||||
|
public List<RecipeDTO> Recipes { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public List<Directions> Directions { get; set; }
|
public string Directions { get; set; }
|
||||||
|
|
||||||
public List<Ingredient> Ingredients { get; set; }
|
public List<Ingredient> Ingredients { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
public List<DirectionsDTO> Directions { get; set; }
|
public string Directions { get; set; }
|
||||||
|
|
||||||
public List<IngredientDTO> Ingredients { get; set; }
|
public List<IngredientDTO> Ingredients { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public double? Amount { get; set; }
|
public double Amount { get; set; }
|
||||||
|
|
||||||
public string? Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public double? Amount { get; set; }
|
public double Amount { get; set; }
|
||||||
|
|
||||||
public string? Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
|
|
||||||
public bool Checked { get; set; }
|
public bool Checked { get; set; }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user