Compare commits
3 Commits
75559daacb
...
f5d580afe7
Author | SHA1 | Date | |
---|---|---|---|
|
f5d580afe7 | ||
|
adcb469a6f | ||
|
4772daa666 |
@ -13,7 +13,7 @@ namespace API.BusinessLogic
|
||||
_dbAccess = dbAccess;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> GetPrefereredRecipes(int userId)
|
||||
public async Task<IActionResult> GetRecipes(int userId)
|
||||
{
|
||||
var recipes = await _dbAccess.ReadRecipes(userId);
|
||||
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);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> CreateRecipe(RecipeDTO recipe, int prefereredRecipesId)
|
||||
public async Task<IActionResult> CreateRecipe(RecipeDTO recipe, int userId)
|
||||
{
|
||||
var prefereredRecipes = await _dbAccess.ReadAllRecipe(prefereredRecipesId);
|
||||
var recipes = await _dbAccess.ReadRecipes(userId);
|
||||
|
||||
foreach (var item in prefereredRecipes.Recipes)
|
||||
foreach (var item in recipes)
|
||||
{
|
||||
if (item.Name == recipe.Name)
|
||||
{
|
||||
@ -42,21 +42,27 @@ namespace API.BusinessLogic
|
||||
}
|
||||
}
|
||||
|
||||
Recipe recipe1 = new Recipe();
|
||||
recipe1.Name = recipe.Name;
|
||||
recipe1.Directions = recipe.Directions;
|
||||
recipe1.Description = recipe.Description;
|
||||
recipe1.Ingredients = new List<Ingredient>();
|
||||
Recipe dish = new Recipe();
|
||||
dish.Name = recipe.Name;
|
||||
dish.Description = recipe.Description;
|
||||
dish.Ingredients = new List<Ingredient>();
|
||||
dish.Directions = new List<Directions>();
|
||||
foreach (var item in recipe.Ingredients)
|
||||
{
|
||||
Ingredient ingredient = new Ingredient();
|
||||
ingredient.Unit = item.Unit;
|
||||
ingredient.Name = item.Name;
|
||||
ingredient.Amount = item.Amount;
|
||||
recipe1.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.CreateRecipe(recipe1, prefereredRecipesId);
|
||||
return await _dbAccess.CreateRecipe(dish, userId);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> EditRecipe(RecipeDTO recipe, int recipeId, int userId)
|
||||
@ -74,7 +80,7 @@ namespace API.BusinessLogic
|
||||
|
||||
dish.Name = recipe.Name;
|
||||
dish.Description = recipe.Description;
|
||||
dish.Directions = recipe.Directions;
|
||||
dish.Directions = new List<Directions>();
|
||||
foreach (var item in recipe.Ingredients)
|
||||
{
|
||||
Ingredient ingredient = new Ingredient();
|
||||
@ -83,6 +89,12 @@ namespace API.BusinessLogic
|
||||
ingredient.Amount = item.Amount;
|
||||
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);
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ namespace API.Controllers
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("getall")]
|
||||
public async Task<IActionResult> ReadPrefereredRecipes()
|
||||
public async Task<IActionResult> ReadRecipes()
|
||||
{
|
||||
var claims = HttpContext.User.Claims;
|
||||
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||
int userId = Convert.ToInt32(userIdString);
|
||||
return await _recipeLogic.GetPrefereredRecipes(userId);
|
||||
return await _recipeLogic.GetRecipes(userId);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
@ -35,10 +35,10 @@ namespace API.Controllers
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("create/{prefereredRecipesId}")]
|
||||
public async Task<IActionResult> CreateRecipe([FromBody] RecipeDTO recipe, int prefereredRecipesId)
|
||||
[HttpPost("create/{RecipesId}")]
|
||||
public async Task<IActionResult> CreateRecipe([FromBody] RecipeDTO recipe, int RecipesId)
|
||||
{
|
||||
return await _recipeLogic.CreateRecipe(recipe, prefereredRecipesId);
|
||||
return await _recipeLogic.CreateRecipe(recipe, RecipesId);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
|
@ -9,8 +9,6 @@ namespace API.DBAccess
|
||||
{
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
public DbSet<PrefereredRecipes> PrefereredRecipes { get; set; }
|
||||
|
||||
public DbSet<Recipe> Recipes { get; set; }
|
||||
|
||||
public DbSet<ShoppingList> ShoppingList { get; set; }
|
||||
|
@ -21,19 +21,14 @@ namespace API.DBAccess
|
||||
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)
|
||||
{
|
||||
return await _context.Recipes.Include(r => r.Ingredients).FirstOrDefaultAsync(r => r.Id == recipeId);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> CreateRecipe(Recipe recipe, int prefereredRecipeId)
|
||||
public async Task<IActionResult> CreateRecipe(Recipe recipe, int userId)
|
||||
{
|
||||
var recipes = await _context.PrefereredRecipes.Include(p => p.Recipes).FirstOrDefaultAsync(p => p.Id == prefereredRecipeId);
|
||||
var recipes = await _context.Users.Include(p => p.Recipes).FirstOrDefaultAsync(u => u.Id == userId);
|
||||
|
||||
recipes.Recipes.Add(recipe);
|
||||
|
||||
|
200
backend/API/Migrations/20250430110454_MadeAmountAndUnitNullable.Designer.cs
generated
Normal file
200
backend/API/Migrations/20250430110454_MadeAmountAndUnitNullable.Designer.cs
generated
Normal file
@ -0,0 +1,200 @@
|
||||
// <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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,175 @@
|
||||
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,14 +19,34 @@ namespace API.Migrations
|
||||
.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<int>("Amount")
|
||||
.HasColumnType("int");
|
||||
b.Property<double?>("Amount")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
@ -36,7 +56,6 @@ namespace API.Migrations
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Unit")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
@ -46,17 +65,6 @@ namespace API.Migrations
|
||||
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")
|
||||
@ -67,24 +75,15 @@ namespace API.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Directions")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("PrefereredRecipesId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("UserId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("PrefereredRecipesId");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("Recipes");
|
||||
@ -96,7 +95,7 @@ namespace API.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Amount")
|
||||
b.Property<double?>("Amount")
|
||||
.HasColumnType("double");
|
||||
|
||||
b.Property<bool>("Checked")
|
||||
@ -107,7 +106,6 @@ namespace API.Migrations
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Unit")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int?>("UserId")
|
||||
@ -152,6 +150,13 @@ namespace API.Migrations
|
||||
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)
|
||||
@ -161,10 +166,6 @@ namespace API.Migrations
|
||||
|
||||
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)
|
||||
.WithMany("Recipes")
|
||||
.HasForeignKey("UserId");
|
||||
@ -177,13 +178,10 @@ namespace API.Migrations
|
||||
.HasForeignKey("UserId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.PrefereredRecipes", b =>
|
||||
{
|
||||
b.Navigation("Recipes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("API.Models.RecipeModels.Recipe", b =>
|
||||
{
|
||||
b.Navigation("Directions");
|
||||
|
||||
b.Navigation("Ingredients");
|
||||
});
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
namespace API.Models.RecipeModels
|
||||
{
|
||||
public class PrefereredRecipes
|
||||
public class Directions
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public List<Recipe> Recipes { get; set; }
|
||||
public string Instruktions { get; set; }
|
||||
}
|
||||
}
|
7
backend/API/Models/RecipeModels/DirectionsDTO.cs
Normal file
7
backend/API/Models/RecipeModels/DirectionsDTO.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace API.Models.RecipeModels
|
||||
{
|
||||
public class DirectionsDTO
|
||||
{
|
||||
public string Instructions { get; set; }
|
||||
}
|
||||
}
|
@ -4,9 +4,9 @@
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int Amount { get; set; }
|
||||
public double? Amount { get; set; }
|
||||
|
||||
public string Unit { get; set; }
|
||||
public string? Unit { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
{
|
||||
public class IngredientDTO
|
||||
{
|
||||
public int Amount { get; set; }
|
||||
public double? Amount { get; set; }
|
||||
|
||||
public string Unit { get; set; }
|
||||
public string? Unit { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
namespace API.Models.RecipeModels
|
||||
{
|
||||
public class PrefereredRecipesDTO
|
||||
{
|
||||
public List<RecipeDTO> Recipes { get; set; }
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Directions { get; set; }
|
||||
public List<Directions> Directions { get; set; }
|
||||
|
||||
public List<Ingredient> Ingredients { get; set; }
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public string Directions { get; set; }
|
||||
public List<DirectionsDTO> Directions { get; set; }
|
||||
|
||||
public List<IngredientDTO> Ingredients { get; set; }
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
{
|
||||
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; }
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
|
||||
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; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user