From 6affee7b8c5c8e3f194faadad657b9abc192c086 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Wed, 5 Mar 2025 17:29:37 +0100 Subject: [PATCH 01/10] Initial Migration --- .gitignore | 1 + .../Models/BackendModels/Favorit/Favorit.cs | 10 ++++++++++ .../Models/BackendModels/File/MediaFile.cs | 11 +++++++++++ .../File/MediaFileImageInstruction.cs | 9 +++++++++ .../BackendModels/File/MediaFileImageRecipe.cs | 9 +++++++++ .../BackendModels/File/MediaFileVideoRecipe.cs | 8 ++++++++ .../Models/BackendModels/Ingredient/Ingredient.cs | 7 ++++++- .../IngredientsShoppingList.cs | 12 ++++++++++++ .../BackendModels/Instruction/Instruction.cs | 2 ++ .../Models/BackendModels/Recipe/Difficulty.cs | 12 ++++++++++++ .../Models/BackendModels/Recipe/Recipe.cs | 14 +++++++++++--- .../RecipeIngredient/RecipeIngredient.cs | 5 +++-- .../BackendModels/Shoppinglist/ShoppingList.cs | 11 +++++++++++ .../Models/BackendModels/Unit/Unit.cs | 14 ++++++++------ 14 files changed, 113 insertions(+), 12 deletions(-) create mode 100644 Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/IngredientShoppingList/IngredientsShoppingList.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs diff --git a/.gitignore b/.gitignore index 61101b4..ad9a362 100644 --- a/.gitignore +++ b/.gitignore @@ -397,3 +397,4 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml src/Recruitment.Tool.xml +/Francesco.Recipes.World/Migrations/20250304095839_AddFewNewBackendModels.Designer.cs diff --git a/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs b/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs new file mode 100644 index 0000000..0e91d0e --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs @@ -0,0 +1,10 @@ +namespace Francesco.Recipes.World.Models.BackendModels.Favorit +{ + using Francesco.Recipes.World.Models.BackendModels.Recipe; + public class Favorit + { + public Guid Id { get; set; } + public DateTime CreatedAt { get; set; } + public virtual Recipe Recipe { get; set; } = new(); + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs new file mode 100644 index 0000000..888a735 --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs @@ -0,0 +1,11 @@ +using Francesco.Recipes.World.Models.BackendModels.File; +using Francesco.Recipes.World.Models.BackendModels.Instruction; +using Francesco.Recipes.World.Models.BackendModels.Recipe; + +public abstract class MediaFile +{ + public Guid Id { get; set; } = Guid.NewGuid(); + public string? FileName { get; set; } + public string? MimeType { get; set; } + public byte[]? Data { get; set; } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs new file mode 100644 index 0000000..70ac229 --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs @@ -0,0 +1,9 @@ +namespace Francesco.Recipes.World.Models.BackendModels.File +{ + using Francesco.Recipes.World.Models.BackendModels.Instruction; + + public class MediaFileImageInstruction : MediaFile + { + public virtual Instruction Instruction { get; set; } + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs new file mode 100644 index 0000000..fdac8c4 --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs @@ -0,0 +1,9 @@ +namespace Francesco.Recipes.World.Models.BackendModels.File +{ + using Francesco.Recipes.World.Models.BackendModels.Recipe; + + public class MediaFileImageRecipe : MediaFile + { + public virtual Recipe Recipe { get; set; } + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs new file mode 100644 index 0000000..14dd710 --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs @@ -0,0 +1,8 @@ +namespace Francesco.Recipes.World.Models.BackendModels.File +{ + using Francesco.Recipes.World.Models.BackendModels.Recipe; + public class MediaFileVideoRecipe : MediaFile + { + public virtual Recipe Recipe { get; set; } + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs index 96f377f..a657e98 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs @@ -1,11 +1,16 @@ namespace Francesco.Recipes.World.Models.BackendModels.Ingredient { + using Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList; + using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; using Francesco.Recipes.World.Models.BackendModels.Unit; + public class Ingredient { public Guid Id { get; set; } public string Name { get; set; } - public virtual Unit Unit { get; set; } = new(); public int Quantity { get; set; } + public virtual ICollection RecipeIngredients { get; set; } = new List(); + public virtual ICollection IngredientShoppingLists { get; set; } = new List(); + public virtual Unit Unit { get; set; } = new(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/IngredientShoppingList/IngredientsShoppingList.cs b/Francesco.Recipes.World/Models/BackendModels/IngredientShoppingList/IngredientsShoppingList.cs new file mode 100644 index 0000000..c527693 --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/IngredientShoppingList/IngredientsShoppingList.cs @@ -0,0 +1,12 @@ +namespace Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList +{ + using Francesco.Recipes.World.Models.BackendModels.Ingredient; + using Francesco.Recipes.World.Models.BackendModels.Shoppinglist; + + public class IngredientsShoppingList + { + public Guid Id { get; set; } + public ShoppingList Shoppinglist { get; set; } = new(); + public Ingredient Ingredient { get; set; } = new(); + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs b/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs index 36a2bd1..ee67e89 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs @@ -1,5 +1,6 @@ namespace Francesco.Recipes.World.Models.BackendModels.Instruction { + using Francesco.Recipes.World.Models.BackendModels.File; using Francesco.Recipes.World.Models.BackendModels.Recipe; public class Instruction { @@ -7,5 +8,6 @@ public string Description { get; set; } public string Number { get; set; } public virtual Recipe Recipe { get; set; } = new(); + public ICollection MediaFileImageInstructions { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs b/Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs new file mode 100644 index 0000000..3c3036e --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs @@ -0,0 +1,12 @@ +namespace Francesco.Recipes.World.Models.BackendModels.Recipe +{ + public enum Difficulty + { + VeryEasy = 1, + Easy = 2, + Medium = 3, + Hard = 4, + Expert = 5 + } + +} diff --git a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs index 1712072..2ce3413 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs @@ -1,5 +1,8 @@ namespace Francesco.Recipes.World.Models.BackendModels.Recipe { + using Francesco.Recipes.World.Models.BackendModels.Category; + using Francesco.Recipes.World.Models.BackendModels.Favorit; + using Francesco.Recipes.World.Models.BackendModels.File; using Francesco.Recipes.World.Models.BackendModels.Instruction; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; @@ -8,11 +11,16 @@ public Guid Id { get; set; } public string Name { get; set; } public string Description { get; set; } - public string Difficulty { get; set; } + public Difficulty Difficulty { get; set; } public int Servings { get; set; } public TimeSpan PreparationTime { get; set; } public TimeSpan CookingTime { get; set; } - public virtual ICollection RecipeIngredients { get; set; } = new List(); - public virtual ICollection Instructions { get; set; } = new List(); + public bool IsFavorite { get; set; } + public virtual ICollection RecipeIngredients { get; set; } = new List(); + public virtual ICollection Instructions { get; set; } = new List(); + public virtual ICollection Images { get; set; } = new List(); + public virtual ICollection Videos { get; set; } = new List(); + public virtual Category Category { get; set; } = new(); + public virtual Favorit Favorit { get; set; } = new(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs b/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs index 79dea52..84ddb82 100644 --- a/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs +++ b/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs @@ -5,7 +5,8 @@ public class RecipeIngredient { public Guid Id { get; set; } - public virtual Recipe Recipe { get; set; } = new (); - public virtual Ingredient Ingredient { get; set; } = new (); + public Guid RecipeId { get; set; } + public virtual Recipe Recipe { get; set; } = new(); + public virtual Ingredient Ingredient { get; set; } = new(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs b/Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs new file mode 100644 index 0000000..bcb1629 --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs @@ -0,0 +1,11 @@ +using Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList; + +namespace Francesco.Recipes.World.Models.BackendModels.Shoppinglist +{ + public class ShoppingList + { + public Guid Id { get; set; } + public DateTime CreatedAt { get; set; } + public virtual ICollection IngredientsShoppingLists { get; set; } = new List(); + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs index 19ba712..3806b7c 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs @@ -1,11 +1,13 @@ -namespace Francesco.Recipes.World.Models.BackendModels.Unit + + +namespace Francesco.Recipes.World.Models.BackendModels.Unit { using Francesco.Recipes.World.Models.BackendModels.Ingredient; - public class Unit { - public Guid Id { get; set; } - public string Name { get; set; } - public virtual ICollection Recipes { get; set; } = new List(); - } + public Guid Id{ get; set; } + public string Name{ get; set; } + public string Symbol { get; set; } + public virtual ICollection Ingredients { get; set; } = new List(); + } } From 449533cf0b65f1f17c5727735f300b627d07ab28 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 12:02:01 +0100 Subject: [PATCH 02/10] Create all Models --- ...0250114131454_InitialMigration.Designer.cs | 230 -------- .../20250114131454_InitialMigration.cs | 184 ------- ...0250318105823_InitialMigration.Designer.cs | 500 ++++++++++++++++++ .../20250318105823_InitialMigration.cs | 342 ++++++++++++ ...escosRecipesWorldDbContextModelSnapshot.cs | 320 ++++++++++- .../Models/BackendModels/Category/Category.cs | 2 +- .../Models/BackendModels/Favorit/Favorit.cs | 2 +- .../Models/BackendModels/File/MediaFile.cs | 11 - .../File/MediaFileImageInstruction.cs | 9 - .../File/MediaFileImageRecipe.cs | 9 - .../File/MediaFileVideoRecipe.cs | 8 - .../BackendModels/ITimeStampedEntity.cs | 9 + .../BackendModels/Ingredient/Ingredient.cs | 4 +- .../BackendModels/Instruction/Instruction.cs | 8 +- .../BackendModels/MediaFile/MediaFile.cs | 17 + .../Models/BackendModels/Recipe/Recipe.cs | 11 +- .../RecipeIngredient/RecipeIngredient.cs | 4 +- .../Models/BackendModels/Unit/Unit.cs | 7 +- 18 files changed, 1182 insertions(+), 495 deletions(-) delete mode 100644 Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.Designer.cs delete mode 100644 Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.cs create mode 100644 Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.Designer.cs create mode 100644 Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.cs delete mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs delete mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs delete mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs delete mode 100644 Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/ITimeStampedEntity.cs create mode 100644 Francesco.Recipes.World/Models/BackendModels/MediaFile/MediaFile.cs diff --git a/Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.Designer.cs b/Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.Designer.cs deleted file mode 100644 index 77d228f..0000000 --- a/Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.Designer.cs +++ /dev/null @@ -1,230 +0,0 @@ -// -using System; -using Francesco.Recipes.World.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Francesco.Recipes.World.Migrations -{ - [DbContext(typeof(FrancescosRecipesWorldDbContext))] - [Migration("20250114131454_InitialMigration")] - partial class InitialMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.11") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Category.Category", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Categories"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Quantity") - .HasColumnType("int"); - - b.Property("UnitId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("UnitId"); - - b.ToTable("Ingredients"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Number") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("RecipeId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("RecipeId"); - - b.ToTable("Instructions"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("CategoryId") - .HasColumnType("uniqueidentifier"); - - b.Property("CookingTime") - .HasColumnType("time"); - - b.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Difficulty") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PreparationTime") - .HasColumnType("time"); - - b.Property("Servings") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("CategoryId"); - - b.ToTable("Recipes"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.RecipeIngredient.RecipeIngredient", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("IngredientId") - .HasColumnType("uniqueidentifier"); - - b.Property("RecipeId") - .HasColumnType("uniqueidentifier"); - - b.HasKey("Id"); - - b.HasIndex("IngredientId"); - - b.HasIndex("RecipeId"); - - b.ToTable("RecipeIngredients"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Name") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Unit"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", b => - { - b.HasOne("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", "Unit") - .WithMany("Recipes") - .HasForeignKey("UnitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Unit"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => - { - b.HasOne("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", "Recipe") - .WithMany("Instructions") - .HasForeignKey("RecipeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Recipe"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => - { - b.HasOne("Francesco.Recipes.World.Models.BackendModels.Category.Category", null) - .WithMany("Recipes") - .HasForeignKey("CategoryId"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.RecipeIngredient.RecipeIngredient", b => - { - b.HasOne("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", "Ingredient") - .WithMany() - .HasForeignKey("IngredientId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", "Recipe") - .WithMany("RecipeIngredients") - .HasForeignKey("RecipeId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Ingredient"); - - b.Navigation("Recipe"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Category.Category", b => - { - b.Navigation("Recipes"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => - { - b.Navigation("Instructions"); - - b.Navigation("RecipeIngredients"); - }); - - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", b => - { - b.Navigation("Recipes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.cs b/Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.cs deleted file mode 100644 index b90b0ed..0000000 --- a/Francesco.Recipes.World/Migrations/20250114131454_InitialMigration.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Francesco.Recipes.World.Migrations -{ - /// - public partial class InitialMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - if (migrationBuilder == null) - { - throw new ArgumentNullException(nameof(migrationBuilder)); - } - - migrationBuilder.CreateTable( - name: "Categories", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Categories", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Unit", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Unit", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Recipes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - Description = table.Column(type: "nvarchar(max)", nullable: false), - Difficulty = table.Column(type: "nvarchar(max)", nullable: false), - Servings = table.Column(type: "int", nullable: false), - PreparationTime = table.Column(type: "time", nullable: false), - CookingTime = table.Column(type: "time", nullable: false), - CategoryId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Recipes", x => x.Id); - table.ForeignKey( - name: "FK_Recipes_Categories_CategoryId", - column: x => x.CategoryId, - principalTable: "Categories", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "Ingredients", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: false), - UnitId = table.Column(type: "uniqueidentifier", nullable: false), - Quantity = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Ingredients", x => x.Id); - table.ForeignKey( - name: "FK_Ingredients_Unit_UnitId", - column: x => x.UnitId, - principalTable: "Unit", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Instructions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Description = table.Column(type: "nvarchar(max)", nullable: false), - Number = table.Column(type: "nvarchar(max)", nullable: false), - RecipeId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Instructions", x => x.Id); - table.ForeignKey( - name: "FK_Instructions_Recipes_RecipeId", - column: x => x.RecipeId, - principalTable: "Recipes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "RecipeIngredients", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - RecipeId = table.Column(type: "uniqueidentifier", nullable: false), - IngredientId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_RecipeIngredients", x => x.Id); - table.ForeignKey( - name: "FK_RecipeIngredients_Ingredients_IngredientId", - column: x => x.IngredientId, - principalTable: "Ingredients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_RecipeIngredients_Recipes_RecipeId", - column: x => x.RecipeId, - principalTable: "Recipes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Ingredients_UnitId", - table: "Ingredients", - column: "UnitId"); - - migrationBuilder.CreateIndex( - name: "IX_Instructions_RecipeId", - table: "Instructions", - column: "RecipeId"); - - migrationBuilder.CreateIndex( - name: "IX_RecipeIngredients_IngredientId", - table: "RecipeIngredients", - column: "IngredientId"); - - migrationBuilder.CreateIndex( - name: "IX_RecipeIngredients_RecipeId", - table: "RecipeIngredients", - column: "RecipeId"); - - migrationBuilder.CreateIndex( - name: "IX_Recipes_CategoryId", - table: "Recipes", - column: "CategoryId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - if (migrationBuilder == null) - { - throw new ArgumentNullException(nameof(migrationBuilder)); - } - - migrationBuilder.DropTable( - name: "Instructions"); - - migrationBuilder.DropTable( - name: "RecipeIngredients"); - - migrationBuilder.DropTable( - name: "Ingredients"); - - migrationBuilder.DropTable( - name: "Recipes"); - - migrationBuilder.DropTable( - name: "Unit"); - - migrationBuilder.DropTable( - name: "Categories"); - } - } -} diff --git a/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.Designer.cs b/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.Designer.cs new file mode 100644 index 0000000..ac67bcb --- /dev/null +++ b/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.Designer.cs @@ -0,0 +1,500 @@ +// +using System; +using Francesco.Recipes.World.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Francesco.Recipes.World.Migrations +{ + [DbContext(typeof(FrancescosRecipesWorldDbContext))] + [Migration("20250318105823_InitialMigration")] + partial class InitialMigration + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Category.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + + b.HasData( + new + { + Id = new Guid("b248244f-f21c-4555-a14d-5dd49a2717cf"), + Name = "Vorspeisen & Snacks" + }, + new + { + Id = new Guid("5186c5d6-5aff-4a6e-baf4-b61b72d889fe"), + Name = "Erste Gänge" + }, + new + { + Id = new Guid("abbc6bb0-97ea-49f5-b31e-6507eb784fd1"), + Name = "Hauptgerichte" + }, + new + { + Id = new Guid("90deec39-dcd0-422d-9018-ac8389e332e1"), + Name = "Desserts & Süßspeisen" + }, + new + { + Id = new Guid("28e39168-701a-4084-81da-d96c987c462f"), + Name = "Beilagen & Salate" + }, + new + { + Id = new Guid("20585b74-4805-4aff-a6df-aa6b7af04ff1"), + Name = "Kuchen" + }, + new + { + Id = new Guid("adfb75ce-3ef3-428b-a5ca-b0c4c619d5ec"), + Name = "Hefegebäck & Brot" + }, + new + { + Id = new Guid("d332f88d-d241-48c5-a2f2-bfd124eada7e"), + Name = "Soßen & Saucen" + }, + new + { + Id = new Guid("23b1c740-e427-44f9-a6ea-d33d3f30f05a"), + Name = "Marmeladen & Eingemachtes" + }, + new + { + Id = new Guid("0a91a200-dc76-4e00-b38c-b38cab5b69d7"), + Name = "Getränke" + }); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Favorit.Favorit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Favorits"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Ingredients"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList.IngredientsShoppingList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("IngredientId") + .HasColumnType("uniqueidentifier"); + + b.Property("ShoppinglistId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("IngredientId"); + + b.HasIndex("ShoppinglistId"); + + b.ToTable("IngredientsShoppingLists"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipeId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RecipeId"); + + b.ToTable("Instructions"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.MediaFile.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Data") + .HasColumnType("varbinary(max)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("InstructionId") + .HasColumnType("uniqueidentifier"); + + b.Property("MimeType") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipeId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("InstructionId"); + + b.HasIndex("RecipeId"); + + b.ToTable("MediaFiles"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CookingTime") + .HasColumnType("time"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Difficulty") + .HasColumnType("int"); + + b.Property("FavoritId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsFavorite") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("PreparationTime") + .HasColumnType("time"); + + b.Property("Servings") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("FavoritId"); + + b.ToTable("Recipes"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.RecipeIngredient.RecipeIngredient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("IngredientId") + .HasColumnType("uniqueidentifier"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("RecipeId") + .HasColumnType("uniqueidentifier"); + + b.Property("UnitId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("IngredientId"); + + b.HasIndex("RecipeId"); + + b.HasIndex("UnitId"); + + b.ToTable("RecipeIngredients"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Shoppinglist.ShoppingList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("ShoppingLists"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Symbol") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Units"); + + b.HasData( + new + { + Id = new Guid("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), + Name = "liter", + Symbol = "l" + }, + new + { + Id = new Guid("6c41f7e6-ca75-49cc-8541-cebd5a9c560b"), + Name = "gramm", + Symbol = "g" + }, + new + { + Id = new Guid("7e3d1b86-ac48-45d6-814e-d3492a86db1d"), + Name = "kilogramm", + Symbol = "kg" + }, + new + { + Id = new Guid("0c3648ec-4981-42c8-abf8-18bf1a2ff4c2"), + Name = "stücke", + Symbol = "stk" + }, + new + { + Id = new Guid("d82f4abd-e4e4-4104-a9c0-1acdeaa701f5"), + Name = "blatt", + Symbol = "blatt" + }, + new + { + Id = new Guid("df5cb4c3-4de6-4c6f-be8c-da41b2986408"), + Name = "messerspitze", + Symbol = "msp" + }, + new + { + Id = new Guid("e45a3af2-2ed6-4ac4-b06f-b4175663a7be"), + Name = "stange", + Symbol = "stange" + }, + new + { + Id = new Guid("7ea2f51d-7493-4f19-a663-1f309186d3ae"), + Name = "bund", + Symbol = "bund" + }, + new + { + Id = new Guid("66556e0e-eb2b-4bc3-9a56-135dd508ed09"), + Name = "zehe", + Symbol = "zehe" + }, + new + { + Id = new Guid("2e9894ac-14fa-43fd-ba07-35cdd8ebd461"), + Name = "teelöffel", + Symbol = "TL" + }, + new + { + Id = new Guid("24a91b89-3389-4465-89e4-2f70d2ea6fd7"), + Name = "esslöffel", + Symbol = "EL" + }); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList.IngredientsShoppingList", b => + { + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", "Ingredient") + .WithMany("IngredientShoppingLists") + .HasForeignKey("IngredientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Shoppinglist.ShoppingList", "Shoppinglist") + .WithMany("IngredientsShoppingLists") + .HasForeignKey("ShoppinglistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ingredient"); + + b.Navigation("Shoppinglist"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => + { + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", "Recipe") + .WithMany("Instructions") + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.MediaFile.MediaFile", b => + { + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", "Instruction") + .WithMany("MediaFiles") + .HasForeignKey("InstructionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", "Recipe") + .WithMany("MediaFiles") + .HasForeignKey("RecipeId"); + + b.Navigation("Instruction"); + + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => + { + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Category.Category", null) + .WithMany("Recipes") + .HasForeignKey("CategoryId"); + + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Favorit.Favorit", "Favorit") + .WithMany("Recipe") + .HasForeignKey("FavoritId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Favorit"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.RecipeIngredient.RecipeIngredient", b => + { + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", "Ingredient") + .WithMany("RecipeIngredients") + .HasForeignKey("IngredientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", "Recipe") + .WithMany("RecipeIngredients") + .HasForeignKey("RecipeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", "Unit") + .WithMany("RecipeIngredient") + .HasForeignKey("UnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ingredient"); + + b.Navigation("Recipe"); + + b.Navigation("Unit"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Category.Category", b => + { + b.Navigation("Recipes"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Favorit.Favorit", b => + { + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", b => + { + b.Navigation("IngredientShoppingLists"); + + b.Navigation("RecipeIngredients"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => + { + b.Navigation("MediaFiles"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => + { + b.Navigation("Instructions"); + + b.Navigation("MediaFiles"); + + b.Navigation("RecipeIngredients"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Shoppinglist.ShoppingList", b => + { + b.Navigation("IngredientsShoppingLists"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", b => + { + b.Navigation("RecipeIngredient"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.cs b/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.cs new file mode 100644 index 0000000..1e8d90d --- /dev/null +++ b/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.cs @@ -0,0 +1,342 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace Francesco.Recipes.World.Migrations +{ + /// + public partial class InitialMigration : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + if (migrationBuilder == null) + { + throw new ArgumentNullException(nameof(migrationBuilder)); + } + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Favorits", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Favorits", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Ingredients", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Ingredients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ShoppingLists", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShoppingLists", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Units", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: true), + Symbol = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Units", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Recipes", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: true), + Description = table.Column(type: "nvarchar(max)", nullable: true), + Difficulty = table.Column(type: "int", nullable: false), + Servings = table.Column(type: "int", nullable: false), + PreparationTime = table.Column(type: "time", nullable: false), + CookingTime = table.Column(type: "time", nullable: false), + IsFavorite = table.Column(type: "bit", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + FavoritId = table.Column(type: "uniqueidentifier", nullable: false), + CategoryId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Recipes", x => x.Id); + table.ForeignKey( + name: "FK_Recipes_Categories_CategoryId", + column: x => x.CategoryId, + principalTable: "Categories", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Recipes_Favorits_FavoritId", + column: x => x.FavoritId, + principalTable: "Favorits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IngredientsShoppingLists", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ShoppinglistId = table.Column(type: "uniqueidentifier", nullable: false), + IngredientId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IngredientsShoppingLists", x => x.Id); + table.ForeignKey( + name: "FK_IngredientsShoppingLists_Ingredients_IngredientId", + column: x => x.IngredientId, + principalTable: "Ingredients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_IngredientsShoppingLists_ShoppingLists_ShoppinglistId", + column: x => x.ShoppinglistId, + principalTable: "ShoppingLists", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Instructions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: true), + Number = table.Column(type: "nvarchar(max)", nullable: true), + RecipeId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Instructions", x => x.Id); + table.ForeignKey( + name: "FK_Instructions_Recipes_RecipeId", + column: x => x.RecipeId, + principalTable: "Recipes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RecipeIngredients", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + RecipeId = table.Column(type: "uniqueidentifier", nullable: false), + IngredientId = table.Column(type: "uniqueidentifier", nullable: false), + UnitId = table.Column(type: "uniqueidentifier", nullable: false), + Quantity = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RecipeIngredients", x => x.Id); + table.ForeignKey( + name: "FK_RecipeIngredients_Ingredients_IngredientId", + column: x => x.IngredientId, + principalTable: "Ingredients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RecipeIngredients_Recipes_RecipeId", + column: x => x.RecipeId, + principalTable: "Recipes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RecipeIngredients_Units_UnitId", + column: x => x.UnitId, + principalTable: "Units", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MediaFiles", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + FileName = table.Column(type: "nvarchar(max)", nullable: true), + MimeType = table.Column(type: "nvarchar(max)", nullable: true), + Data = table.Column(type: "varbinary(max)", nullable: true), + RecipeId = table.Column(type: "uniqueidentifier", nullable: true), + InstructionId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MediaFiles", x => x.Id); + table.ForeignKey( + name: "FK_MediaFiles_Instructions_InstructionId", + column: x => x.InstructionId, + principalTable: "Instructions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_MediaFiles_Recipes_RecipeId", + column: x => x.RecipeId, + principalTable: "Recipes", + principalColumn: "Id"); + }); + + migrationBuilder.InsertData( + table: "Categories", + columns: new[] { "Id", "Name" }, + values: new object[,] + { + { new Guid("0a91a200-dc76-4e00-b38c-b38cab5b69d7"), "Getränke" }, + { new Guid("20585b74-4805-4aff-a6df-aa6b7af04ff1"), "Kuchen" }, + { new Guid("23b1c740-e427-44f9-a6ea-d33d3f30f05a"), "Marmeladen & Eingemachtes" }, + { new Guid("28e39168-701a-4084-81da-d96c987c462f"), "Beilagen & Salate" }, + { new Guid("5186c5d6-5aff-4a6e-baf4-b61b72d889fe"), "Erste Gänge" }, + { new Guid("90deec39-dcd0-422d-9018-ac8389e332e1"), "Desserts & Süßspeisen" }, + { new Guid("abbc6bb0-97ea-49f5-b31e-6507eb784fd1"), "Hauptgerichte" }, + { new Guid("adfb75ce-3ef3-428b-a5ca-b0c4c619d5ec"), "Hefegebäck & Brot" }, + { new Guid("b248244f-f21c-4555-a14d-5dd49a2717cf"), "Vorspeisen & Snacks" }, + { new Guid("d332f88d-d241-48c5-a2f2-bfd124eada7e"), "Soßen & Saucen" } + }); + + migrationBuilder.InsertData( + table: "Units", + columns: new[] { "Id", "Name", "Symbol" }, + values: new object[,] + { + { new Guid("0c3648ec-4981-42c8-abf8-18bf1a2ff4c2"), "stücke", "stk" }, + { new Guid("24a91b89-3389-4465-89e4-2f70d2ea6fd7"), "esslöffel", "EL" }, + { new Guid("2e9894ac-14fa-43fd-ba07-35cdd8ebd461"), "teelöffel", "TL" }, + { new Guid("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), "liter", "l" }, + { new Guid("66556e0e-eb2b-4bc3-9a56-135dd508ed09"), "zehe", "zehe" }, + { new Guid("6c41f7e6-ca75-49cc-8541-cebd5a9c560b"), "gramm", "g" }, + { new Guid("7e3d1b86-ac48-45d6-814e-d3492a86db1d"), "kilogramm", "kg" }, + { new Guid("7ea2f51d-7493-4f19-a663-1f309186d3ae"), "bund", "bund" }, + { new Guid("d82f4abd-e4e4-4104-a9c0-1acdeaa701f5"), "blatt", "blatt" }, + { new Guid("df5cb4c3-4de6-4c6f-be8c-da41b2986408"), "messerspitze", "msp" }, + { new Guid("e45a3af2-2ed6-4ac4-b06f-b4175663a7be"), "stange", "stange" } + }); + + migrationBuilder.CreateIndex( + name: "IX_IngredientsShoppingLists_IngredientId", + table: "IngredientsShoppingLists", + column: "IngredientId"); + + migrationBuilder.CreateIndex( + name: "IX_IngredientsShoppingLists_ShoppinglistId", + table: "IngredientsShoppingLists", + column: "ShoppinglistId"); + + migrationBuilder.CreateIndex( + name: "IX_Instructions_RecipeId", + table: "Instructions", + column: "RecipeId"); + + migrationBuilder.CreateIndex( + name: "IX_MediaFiles_InstructionId", + table: "MediaFiles", + column: "InstructionId"); + + migrationBuilder.CreateIndex( + name: "IX_MediaFiles_RecipeId", + table: "MediaFiles", + column: "RecipeId"); + + migrationBuilder.CreateIndex( + name: "IX_RecipeIngredients_IngredientId", + table: "RecipeIngredients", + column: "IngredientId"); + + migrationBuilder.CreateIndex( + name: "IX_RecipeIngredients_RecipeId", + table: "RecipeIngredients", + column: "RecipeId"); + + migrationBuilder.CreateIndex( + name: "IX_RecipeIngredients_UnitId", + table: "RecipeIngredients", + column: "UnitId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_CategoryId", + table: "Recipes", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Recipes_FavoritId", + table: "Recipes", + column: "FavoritId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + if (migrationBuilder == null) + { + throw new ArgumentNullException(nameof(migrationBuilder)); + } + migrationBuilder.DropTable( + name: "IngredientsShoppingLists"); + + migrationBuilder.DropTable( + name: "MediaFiles"); + + migrationBuilder.DropTable( + name: "RecipeIngredients"); + + migrationBuilder.DropTable( + name: "ShoppingLists"); + + migrationBuilder.DropTable( + name: "Instructions"); + + migrationBuilder.DropTable( + name: "Ingredients"); + + migrationBuilder.DropTable( + name: "Units"); + + migrationBuilder.DropTable( + name: "Recipes"); + + migrationBuilder.DropTable( + name: "Categories"); + + migrationBuilder.DropTable( + name: "Favorits"); + } + } +} diff --git a/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs b/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs index 309c9b2..06d6ff4 100644 --- a/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs +++ b/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs @@ -29,12 +29,77 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") - .IsRequired() .HasColumnType("nvarchar(max)"); b.HasKey("Id"); b.ToTable("Categories"); + + b.HasData( + new + { + Id = new Guid("b248244f-f21c-4555-a14d-5dd49a2717cf"), + Name = "Vorspeisen & Snacks" + }, + new + { + Id = new Guid("5186c5d6-5aff-4a6e-baf4-b61b72d889fe"), + Name = "Erste Gänge" + }, + new + { + Id = new Guid("abbc6bb0-97ea-49f5-b31e-6507eb784fd1"), + Name = "Hauptgerichte" + }, + new + { + Id = new Guid("90deec39-dcd0-422d-9018-ac8389e332e1"), + Name = "Desserts & Süßspeisen" + }, + new + { + Id = new Guid("28e39168-701a-4084-81da-d96c987c462f"), + Name = "Beilagen & Salate" + }, + new + { + Id = new Guid("20585b74-4805-4aff-a6df-aa6b7af04ff1"), + Name = "Kuchen" + }, + new + { + Id = new Guid("adfb75ce-3ef3-428b-a5ca-b0c4c619d5ec"), + Name = "Hefegebäck & Brot" + }, + new + { + Id = new Guid("d332f88d-d241-48c5-a2f2-bfd124eada7e"), + Name = "Soßen & Saucen" + }, + new + { + Id = new Guid("23b1c740-e427-44f9-a6ea-d33d3f30f05a"), + Name = "Marmeladen & Eingemachtes" + }, + new + { + Id = new Guid("0a91a200-dc76-4e00-b38c-b38cab5b69d7"), + Name = "Getränke" + }); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Favorit.Favorit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Favorits"); }); modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", b => @@ -44,20 +109,32 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") - .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Quantity") - .HasColumnType("int"); + b.HasKey("Id"); - b.Property("UnitId") + b.ToTable("Ingredients"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList.IngredientsShoppingList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("IngredientId") + .HasColumnType("uniqueidentifier"); + + b.Property("ShoppinglistId") .HasColumnType("uniqueidentifier"); b.HasKey("Id"); - b.HasIndex("UnitId"); + b.HasIndex("IngredientId"); - b.ToTable("Ingredients"); + b.HasIndex("ShoppinglistId"); + + b.ToTable("IngredientsShoppingLists"); }); modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => @@ -67,11 +144,9 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Description") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Number") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("RecipeId") @@ -84,6 +159,36 @@ namespace Francesco.Recipes.World.Migrations b.ToTable("Instructions"); }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.MediaFile.MediaFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Data") + .HasColumnType("varbinary(max)"); + + b.Property("FileName") + .HasColumnType("nvarchar(max)"); + + b.Property("InstructionId") + .HasColumnType("uniqueidentifier"); + + b.Property("MimeType") + .HasColumnType("nvarchar(max)"); + + b.Property("RecipeId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("InstructionId"); + + b.HasIndex("RecipeId"); + + b.ToTable("MediaFiles"); + }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => { b.Property("Id") @@ -96,16 +201,22 @@ namespace Francesco.Recipes.World.Migrations b.Property("CookingTime") .HasColumnType("time"); + b.Property("CreatedAt") + .HasColumnType("datetime2"); + b.Property("Description") - .IsRequired() .HasColumnType("nvarchar(max)"); - b.Property("Difficulty") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Difficulty") + .HasColumnType("int"); + + b.Property("FavoritId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsFavorite") + .HasColumnType("bit"); b.Property("Name") - .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("PreparationTime") @@ -118,6 +229,8 @@ namespace Francesco.Recipes.World.Migrations b.HasIndex("CategoryId"); + b.HasIndex("FavoritId"); + b.ToTable("Recipes"); }); @@ -130,18 +243,40 @@ namespace Francesco.Recipes.World.Migrations b.Property("IngredientId") .HasColumnType("uniqueidentifier"); + b.Property("Quantity") + .HasColumnType("int"); + b.Property("RecipeId") .HasColumnType("uniqueidentifier"); + b.Property("UnitId") + .HasColumnType("uniqueidentifier"); + b.HasKey("Id"); b.HasIndex("IngredientId"); b.HasIndex("RecipeId"); + b.HasIndex("UnitId"); + b.ToTable("RecipeIngredients"); }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Shoppinglist.ShoppingList", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("ShoppingLists"); + }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", b => { b.Property("Id") @@ -149,23 +284,101 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") - .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Symbol") .HasColumnType("nvarchar(max)"); b.HasKey("Id"); - b.ToTable("Unit"); + b.ToTable("Units"); + + b.HasData( + new + { + Id = new Guid("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), + Name = "liter", + Symbol = "l" + }, + new + { + Id = new Guid("6c41f7e6-ca75-49cc-8541-cebd5a9c560b"), + Name = "gramm", + Symbol = "g" + }, + new + { + Id = new Guid("7e3d1b86-ac48-45d6-814e-d3492a86db1d"), + Name = "kilogramm", + Symbol = "kg" + }, + new + { + Id = new Guid("0c3648ec-4981-42c8-abf8-18bf1a2ff4c2"), + Name = "stücke", + Symbol = "stk" + }, + new + { + Id = new Guid("d82f4abd-e4e4-4104-a9c0-1acdeaa701f5"), + Name = "blatt", + Symbol = "blatt" + }, + new + { + Id = new Guid("df5cb4c3-4de6-4c6f-be8c-da41b2986408"), + Name = "messerspitze", + Symbol = "msp" + }, + new + { + Id = new Guid("e45a3af2-2ed6-4ac4-b06f-b4175663a7be"), + Name = "stange", + Symbol = "stange" + }, + new + { + Id = new Guid("7ea2f51d-7493-4f19-a663-1f309186d3ae"), + Name = "bund", + Symbol = "bund" + }, + new + { + Id = new Guid("66556e0e-eb2b-4bc3-9a56-135dd508ed09"), + Name = "zehe", + Symbol = "zehe" + }, + new + { + Id = new Guid("2e9894ac-14fa-43fd-ba07-35cdd8ebd461"), + Name = "teelöffel", + Symbol = "TL" + }, + new + { + Id = new Guid("24a91b89-3389-4465-89e4-2f70d2ea6fd7"), + Name = "esslöffel", + Symbol = "EL" + }); }); - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", b => + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList.IngredientsShoppingList", b => { - b.HasOne("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", "Unit") - .WithMany("Recipes") - .HasForeignKey("UnitId") + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", "Ingredient") + .WithMany("IngredientShoppingLists") + .HasForeignKey("IngredientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("Unit"); + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Shoppinglist.ShoppingList", "Shoppinglist") + .WithMany("IngredientsShoppingLists") + .HasForeignKey("ShoppinglistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ingredient"); + + b.Navigation("Shoppinglist"); }); modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => @@ -179,17 +392,42 @@ namespace Francesco.Recipes.World.Migrations b.Navigation("Recipe"); }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.MediaFile.MediaFile", b => + { + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", "Instruction") + .WithMany("MediaFiles") + .HasForeignKey("InstructionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", "Recipe") + .WithMany("MediaFiles") + .HasForeignKey("RecipeId"); + + b.Navigation("Instruction"); + + b.Navigation("Recipe"); + }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => { b.HasOne("Francesco.Recipes.World.Models.BackendModels.Category.Category", null) .WithMany("Recipes") .HasForeignKey("CategoryId"); + + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Favorit.Favorit", "Favorit") + .WithMany("Recipe") + .HasForeignKey("FavoritId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Favorit"); }); modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.RecipeIngredient.RecipeIngredient", b => { b.HasOne("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", "Ingredient") - .WithMany() + .WithMany("RecipeIngredients") .HasForeignKey("IngredientId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -200,9 +438,17 @@ namespace Francesco.Recipes.World.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", "Unit") + .WithMany("RecipeIngredient") + .HasForeignKey("UnitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.Navigation("Ingredient"); b.Navigation("Recipe"); + + b.Navigation("Unit"); }); modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Category.Category", b => @@ -210,16 +456,40 @@ namespace Francesco.Recipes.World.Migrations b.Navigation("Recipes"); }); - modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Favorit.Favorit", b => { - b.Navigation("Instructions"); + b.Navigation("Recipe"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Ingredient.Ingredient", b => + { + b.Navigation("IngredientShoppingLists"); b.Navigation("RecipeIngredients"); }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Instruction.Instruction", b => + { + b.Navigation("MediaFiles"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Recipe.Recipe", b => + { + b.Navigation("Instructions"); + + b.Navigation("MediaFiles"); + + b.Navigation("RecipeIngredients"); + }); + + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Shoppinglist.ShoppingList", b => + { + b.Navigation("IngredientsShoppingLists"); + }); + modelBuilder.Entity("Francesco.Recipes.World.Models.BackendModels.Unit.Unit", b => { - b.Navigation("Recipes"); + b.Navigation("RecipeIngredient"); }); #pragma warning restore 612, 618 } diff --git a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs index 5fa42d4..64934a2 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs @@ -4,7 +4,7 @@ public class Category { public Guid Id { get; set; } - public string Name { get; set; } + public string? Name { get; set; } public virtual ICollection Recipes { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs b/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs index 0e91d0e..538dd99 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs @@ -5,6 +5,6 @@ { public Guid Id { get; set; } public DateTime CreatedAt { get; set; } - public virtual Recipe Recipe { get; set; } = new(); + public virtual ICollection Recipe { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs deleted file mode 100644 index 888a735..0000000 --- a/Francesco.Recipes.World/Models/BackendModels/File/MediaFile.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Francesco.Recipes.World.Models.BackendModels.File; -using Francesco.Recipes.World.Models.BackendModels.Instruction; -using Francesco.Recipes.World.Models.BackendModels.Recipe; - -public abstract class MediaFile -{ - public Guid Id { get; set; } = Guid.NewGuid(); - public string? FileName { get; set; } - public string? MimeType { get; set; } - public byte[]? Data { get; set; } -} diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs deleted file mode 100644 index 70ac229..0000000 --- a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageInstruction.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Francesco.Recipes.World.Models.BackendModels.File -{ - using Francesco.Recipes.World.Models.BackendModels.Instruction; - - public class MediaFileImageInstruction : MediaFile - { - public virtual Instruction Instruction { get; set; } - } -} diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs deleted file mode 100644 index fdac8c4..0000000 --- a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileImageRecipe.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Francesco.Recipes.World.Models.BackendModels.File -{ - using Francesco.Recipes.World.Models.BackendModels.Recipe; - - public class MediaFileImageRecipe : MediaFile - { - public virtual Recipe Recipe { get; set; } - } -} diff --git a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs b/Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs deleted file mode 100644 index 14dd710..0000000 --- a/Francesco.Recipes.World/Models/BackendModels/File/MediaFileVideoRecipe.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Francesco.Recipes.World.Models.BackendModels.File -{ - using Francesco.Recipes.World.Models.BackendModels.Recipe; - public class MediaFileVideoRecipe : MediaFile - { - public virtual Recipe Recipe { get; set; } - } -} diff --git a/Francesco.Recipes.World/Models/BackendModels/ITimeStampedEntity.cs b/Francesco.Recipes.World/Models/BackendModels/ITimeStampedEntity.cs new file mode 100644 index 0000000..baa9f35 --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/ITimeStampedEntity.cs @@ -0,0 +1,9 @@ +namespace Francesco.Recipes.World.Models.BackendModels +{ + public interface ITimeStampedEntity + { + DateTime CreatedAt { get; set; } + + DateTime? ModifiedAt { get; set; } + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs index a657e98..291da18 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs @@ -7,10 +7,8 @@ public class Ingredient { public Guid Id { get; set; } - public string Name { get; set; } - public int Quantity { get; set; } + public string? Name { get; set; } public virtual ICollection RecipeIngredients { get; set; } = new List(); public virtual ICollection IngredientShoppingLists { get; set; } = new List(); - public virtual Unit Unit { get; set; } = new(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs b/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs index ee67e89..fc14bd6 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs @@ -1,13 +1,13 @@ namespace Francesco.Recipes.World.Models.BackendModels.Instruction { - using Francesco.Recipes.World.Models.BackendModels.File; + using Francesco.Recipes.World.Models.BackendModels.MediaFile; using Francesco.Recipes.World.Models.BackendModels.Recipe; public class Instruction { public Guid Id { get; set; } - public string Description { get; set; } - public string Number { get; set; } + public string? Description { get; set; } + public string? Number { get; set; } public virtual Recipe Recipe { get; set; } = new(); - public ICollection MediaFileImageInstructions { get; set; } = new List(); + public virtual ICollection MediaFiles { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/MediaFile/MediaFile.cs b/Francesco.Recipes.World/Models/BackendModels/MediaFile/MediaFile.cs new file mode 100644 index 0000000..56c083a --- /dev/null +++ b/Francesco.Recipes.World/Models/BackendModels/MediaFile/MediaFile.cs @@ -0,0 +1,17 @@ +namespace Francesco.Recipes.World.Models.BackendModels.MediaFile +{ + using Francesco.Recipes.World.Models.BackendModels.Instruction; + using Francesco.Recipes.World.Models.BackendModels.Recipe; + public class MediaFile + { + public Guid Id { get; set; } = Guid.NewGuid(); + + public string? FileName { get; set; } + + public string? MimeType { get; set; } + + public byte[]? Data { get; set; } + public virtual Recipe? Recipe { get; set; } = new(); + public virtual Instruction Instruction { get; set; } = new(); + } +} diff --git a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs index 2ce3413..6c352a5 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs @@ -2,25 +2,24 @@ { using Francesco.Recipes.World.Models.BackendModels.Category; using Francesco.Recipes.World.Models.BackendModels.Favorit; - using Francesco.Recipes.World.Models.BackendModels.File; using Francesco.Recipes.World.Models.BackendModels.Instruction; + using Francesco.Recipes.World.Models.BackendModels.MediaFile; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; public class Recipe { public Guid Id { get; set; } - public string Name { get; set; } - public string Description { get; set; } + public string? Name { get; set; } + public string? Description { get; set; } public Difficulty Difficulty { get; set; } public int Servings { get; set; } public TimeSpan PreparationTime { get; set; } public TimeSpan CookingTime { get; set; } public bool IsFavorite { get; set; } + public DateTime CreatedAt { get; set; } public virtual ICollection RecipeIngredients { get; set; } = new List(); public virtual ICollection Instructions { get; set; } = new List(); - public virtual ICollection Images { get; set; } = new List(); - public virtual ICollection Videos { get; set; } = new List(); - public virtual Category Category { get; set; } = new(); + public virtual ICollection MediaFiles { get; set; } = new List(); public virtual Favorit Favorit { get; set; } = new(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs b/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs index 84ddb82..30456ad 100644 --- a/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs +++ b/Francesco.Recipes.World/Models/BackendModels/RecipeIngredient/RecipeIngredient.cs @@ -2,11 +2,13 @@ { using Francesco.Recipes.World.Models.BackendModels.Ingredient; using Francesco.Recipes.World.Models.BackendModels.Recipe; + using Francesco.Recipes.World.Models.BackendModels.Unit; public class RecipeIngredient { public Guid Id { get; set; } - public Guid RecipeId { get; set; } public virtual Recipe Recipe { get; set; } = new(); public virtual Ingredient Ingredient { get; set; } = new(); + public virtual Unit Unit { get; set; } = new(); + public int Quantity { get; set; } } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs index 3806b7c..902657a 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs @@ -3,11 +3,12 @@ namespace Francesco.Recipes.World.Models.BackendModels.Unit { using Francesco.Recipes.World.Models.BackendModels.Ingredient; + using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; public class Unit { public Guid Id{ get; set; } - public string Name{ get; set; } - public string Symbol { get; set; } - public virtual ICollection Ingredients { get; set; } = new List(); + public string? Name { get; set; } + public string? Symbol { get; set; } + public virtual ICollection RecipeIngredient { get; set; } = new List(); } } From 36e107d48e874407f0cec1db83b35d7a77579426 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 13:15:08 +0100 Subject: [PATCH 03/10] Fixed some properties on models --- .../Models/BackendModels/Ingredient/Ingredient.cs | 2 +- .../Models/BackendModels/Instruction/Instruction.cs | 4 ++-- .../Models/BackendModels/Recipe/Recipe.cs | 6 +++--- .../Models/BackendModels/Shoppinglist/ShoppingList.cs | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs index 291da18..f8bf8eb 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs @@ -7,7 +7,7 @@ public class Ingredient { public Guid Id { get; set; } - public string? Name { get; set; } + public string Name { get; set; } public virtual ICollection RecipeIngredients { get; set; } = new List(); public virtual ICollection IngredientShoppingLists { get; set; } = new List(); } diff --git a/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs b/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs index fc14bd6..6f0919c 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Instruction/Instruction.cs @@ -5,8 +5,8 @@ public class Instruction { public Guid Id { get; set; } - public string? Description { get; set; } - public string? Number { get; set; } + public string Description { get; set; } + public string Number { get; set; } public virtual Recipe Recipe { get; set; } = new(); public virtual ICollection MediaFiles { get; set; } = new List(); } diff --git a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs index 6c352a5..68d180c 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs @@ -6,10 +6,10 @@ using Francesco.Recipes.World.Models.BackendModels.MediaFile; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; - public class Recipe + public class Recipe : ITimeStampedEntity { public Guid Id { get; set; } - public string? Name { get; set; } + public string Name { get; set; } public string? Description { get; set; } public Difficulty Difficulty { get; set; } public int Servings { get; set; } @@ -17,9 +17,9 @@ public TimeSpan CookingTime { get; set; } public bool IsFavorite { get; set; } public DateTime CreatedAt { get; set; } + public DateTime? ModifiedAt { get; set; } public virtual ICollection RecipeIngredients { get; set; } = new List(); public virtual ICollection Instructions { get; set; } = new List(); public virtual ICollection MediaFiles { get; set; } = new List(); public virtual Favorit Favorit { get; set; } = new(); } -} diff --git a/Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs b/Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs index bcb1629..a6f764e 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Shoppinglist/ShoppingList.cs @@ -2,10 +2,11 @@ namespace Francesco.Recipes.World.Models.BackendModels.Shoppinglist { - public class ShoppingList + public class ShoppingList : ITimeStampedEntity { public Guid Id { get; set; } public DateTime CreatedAt { get; set; } + public DateTime? ModifiedAt { get; set; } public virtual ICollection IngredientsShoppingLists { get; set; } = new List(); } } From 45702aa4f2fe4ea29a671744243d755370aeb384 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 13:54:37 +0100 Subject: [PATCH 04/10] Correct Models Unit and Category --- .gitignore | 1 - .../Controllers/Favorit/FavoritController.cs | 6 + .../Ingredient/IngredientController.cs | 6 + .../Instruction/InstructionController.cs | 6 + .../MediaFile/MediaFilesController.cs | 9 ++ .../Controllers/Recipe/RecipeController.cs | 6 + .../ShoppingList/ShoppingLIstController.cs | 6 + .../Data/FrancescosRecipesWorldDbContext.cs | 111 +++++++++++++++--- .../Repository/Category/CategoryRepository.cs | 6 + .../Category/ICategoryRepository.cs | 6 + .../Data/Repository/ErrorViewModel.cs | 9 ++ .../Repository/Favorit/FavoritRepository.cs | 6 + .../Repository/Favorit/IFavoritRepository.cs | 6 + .../Ingredient/IIngredientRepository.cs | 17 +++ .../Ingredient/IngredientRepository.cs | 66 +++++++++++ .../Instruction/IInstructionsRepository.cs | 6 + .../Instruction/InstructionsRepository.cs | 6 + .../MediaFile/IMediaFileRepository.cs | 6 + .../MediaFile/MediaFileRepository.cs | 6 + .../Repository/Recipe/IRecipeRepository.cs | 6 + .../Repository/Recipe/RecipeRepository.cs | 6 + .../ShoppingLIst/IShoppingListRepository.cs | 6 + .../ShoppingLIst/ShoppingListRepository.cs | 6 + .../Data/Repository/Unit/IUnitRepository.cs | 6 + .../Data/Repository/Unit/UnitRepository.cs | 6 + .../Francesco.Recipes.World.csproj | 5 + .../Models/BackendModels/Category/Category.cs | 2 +- .../Models/BackendModels/Unit/Unit.cs | 4 +- .../Services/Category/CategoryService.cs | 6 + .../Services/Favorit/FavoritService.cs | 6 + .../Services/Ingredient/IngredientService.cs | 6 + .../Instruction/InstructionsService.cs | 6 + .../Services/MediaFile/MediaFileService.cs | 6 + .../Services/Recipe/RecipeService.cs | 6 + .../ShoppingLIst/ShoppingListService.cs | 6 + .../Services/Unit/UnitService.cs | 6 + 36 files changed, 368 insertions(+), 18 deletions(-) create mode 100644 Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs create mode 100644 Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs create mode 100644 Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs create mode 100644 Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs create mode 100644 Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs create mode 100644 Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs create mode 100644 Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs create mode 100644 Francesco.Recipes.World/Services/Category/CategoryService.cs create mode 100644 Francesco.Recipes.World/Services/Favorit/FavoritService.cs create mode 100644 Francesco.Recipes.World/Services/Ingredient/IngredientService.cs create mode 100644 Francesco.Recipes.World/Services/Instruction/InstructionsService.cs create mode 100644 Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs create mode 100644 Francesco.Recipes.World/Services/Recipe/RecipeService.cs create mode 100644 Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs create mode 100644 Francesco.Recipes.World/Services/Unit/UnitService.cs diff --git a/.gitignore b/.gitignore index ad9a362..61101b4 100644 --- a/.gitignore +++ b/.gitignore @@ -397,4 +397,3 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml src/Recruitment.Tool.xml -/Francesco.Recipes.World/Migrations/20250304095839_AddFewNewBackendModels.Designer.cs diff --git a/Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs b/Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs new file mode 100644 index 0000000..7d66c1f --- /dev/null +++ b/Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Controllers.Favorit +{ + public class FavoritController + { + } +} diff --git a/Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs b/Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs new file mode 100644 index 0000000..187acb8 --- /dev/null +++ b/Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Controllers.Ingredient +{ + public class IngredientController + { + } +} diff --git a/Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs b/Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs new file mode 100644 index 0000000..17c9b8d --- /dev/null +++ b/Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Controllers.Instruction +{ + public class InstructionController + { + } +} diff --git a/Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs b/Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs new file mode 100644 index 0000000..d17c5fd --- /dev/null +++ b/Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs @@ -0,0 +1,9 @@ +namespace Francesco.Recipes.World.Controllers.MediaFile +{ + using Microsoft.AspNetCore.Mvc; + + public class MediaFilesController : Controller + { + + } +} diff --git a/Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs b/Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs new file mode 100644 index 0000000..a4b93ae --- /dev/null +++ b/Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Controllers.Recipe +{ + public class RecipeController + { + } +} diff --git a/Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs b/Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs new file mode 100644 index 0000000..03e77c6 --- /dev/null +++ b/Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Controllers.ShoppingList +{ + public class ShoppingLIstController + { + } +} diff --git a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs index fe4646e..e27bf78 100644 --- a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs +++ b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs @@ -1,25 +1,108 @@ -namespace Francesco.Recipes.World.Data -{ - using Francesco.Recipes.World.Models.BackendModels.Category; +namespace Francesco.Recipes.World.Data; + +using System.Runtime.CompilerServices; +using Francesco.Recipes.World.Models.BackendModels; +using Francesco.Recipes.World.Models.BackendModels.Category; + using Francesco.Recipes.World.Models.BackendModels.Favorit; using Francesco.Recipes.World.Models.BackendModels.Ingredient; + using Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList; using Francesco.Recipes.World.Models.BackendModels.Instruction; + using Francesco.Recipes.World.Models.BackendModels.MediaFile; using Francesco.Recipes.World.Models.BackendModels.Recipe; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; + using Francesco.Recipes.World.Models.BackendModels.Shoppinglist; using Francesco.Recipes.World.Models.BackendModels.Unit; - using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; - public class FrancescosRecipesWorldDbContext : DbContext +public class FrancescosRecipesWorldDbContext : DbContext +{ + public FrancescosRecipesWorldDbContext(DbContextOptions options) + : base(options) { - public FrancescosRecipesWorldDbContext(DbContextOptions options) - : base(options) - { + } + + public DbSet Categories => Set(); + public DbSet Ingredients => Set(); + public DbSet Instructions => Set(); + public DbSet Recipes => Set(); + public DbSet RecipeIngredients => Set(); + public DbSet Units => Set(); + public DbSet Favorits => Set(); + public DbSet IngredientsShoppingLists => Set(); + public DbSet ShoppingLists => Set(); + public DbSet MediaFiles => Set(); + public override Task SaveChangesAsync(CancellationToken cancellationToken = default) + { + foreach (var entry in ChangeTracker.Entries()) + { + if (entry.Entity is ITimeStampedEntity timeStampedEntity) + { + switch (entry.State) + { + case EntityState.Added: + timeStampedEntity.CreatedAt = DateTime.UtcNow; + break; + case EntityState.Modified: + timeStampedEntity.ModifiedAt = DateTime.UtcNow; + break; + } + } } - public DbSet Categories => Set(); - public DbSet Ingredients => Set(); - public DbSet Instructions => Set(); - public DbSet Recipes => Set(); - public DbSet RecipeIngredients => Set(); - public DbSet Units => Set(); + return base.SaveChangesAsync(cancellationToken); + } + protected override void OnModelCreating(ModelBuilder builder) + { + if (builder is null) + { + throw new ArgumentNullException(nameof(builder)); + } + + SeedData(builder); + + base.OnModelCreating(builder); + } + + private static void SeedData(ModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasData(GetCategories()); + + modelBuilder.Entity() + .HasData(GetUnits()); + } + private static IEnumerable GetCategories() + { + return new List() + { + new Category { Id = Guid.Parse("b248244f-f21c-4555-a14d-5dd49a2717cf"), Name = "Vorspeisen & Snacks" }, + new Category { Id = Guid.Parse("5186c5d6-5aff-4a6e-baf4-b61b72d889fe"), Name = "Erste Gänge" }, + new Category { Id = Guid.Parse("abbc6bb0-97ea-49f5-b31e-6507eb784fd1"), Name = "Hauptgerichte" }, + new Category { Id = Guid.Parse("90deec39-dcd0-422d-9018-ac8389e332e1"), Name = "Desserts & Süßspeisen" }, + new Category { Id = Guid.Parse("28e39168-701a-4084-81da-d96c987c462f"), Name = "Beilagen & Salate" }, + new Category { Id = Guid.Parse("20585b74-4805-4aff-a6df-aa6b7af04ff1"), Name = "Kuchen" }, + new Category { Id = Guid.Parse("adfb75ce-3ef3-428b-a5ca-b0c4c619d5ec"), Name = "Hefegebäck & Brot" }, + new Category { Id = Guid.Parse("d332f88d-d241-48c5-a2f2-bfd124eada7e"), Name = "Soßen & Saucen" }, + new Category { Id = Guid.Parse("23b1c740-e427-44f9-a6ea-d33d3f30f05a"), Name = "Marmeladen & Eingemachtes" }, + new Category { Id = Guid.Parse("0a91a200-dc76-4e00-b38c-b38cab5b69d7"), Name = "Getränke" }, + }; + } + + private static IEnumerable GetUnits() + { + return new List() + { + new Unit { Id = Guid.Parse("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), Name = "liter", Symbol = "l" }, + new Unit { Id = Guid.Parse("6c41f7e6-ca75-49cc-8541-cebd5a9c560b"), Name = "gramm", Symbol = "g" }, + new Unit { Id = Guid.Parse("7e3d1b86-ac48-45d6-814e-d3492a86db1d"), Name = "kilogramm", Symbol = "kg" }, + new Unit { Id = Guid.Parse("0c3648ec-4981-42c8-abf8-18bf1a2ff4c2"), Name = "stücke", Symbol = "stk" }, + new Unit { Id = Guid.Parse("d82f4abd-e4e4-4104-a9c0-1acdeaa701f5"), Name = "blatt", Symbol = "blatt" }, + new Unit { Id = Guid.Parse("df5cb4c3-4de6-4c6f-be8c-da41b2986408"), Name = "messerspitze", Symbol = "msp" }, + new Unit { Id = Guid.Parse("e45a3af2-2ed6-4ac4-b06f-b4175663a7be"), Name = "stange", Symbol = "stange" }, + new Unit { Id = Guid.Parse("7ea2f51d-7493-4f19-a663-1f309186d3ae"), Name = "bund", Symbol = "bund" }, + new Unit { Id = Guid.Parse("66556e0e-eb2b-4bc3-9a56-135dd508ed09"), Name = "zehe", Symbol = "zehe" }, + new Unit { Id = Guid.Parse("2e9894ac-14fa-43fd-ba07-35cdd8ebd461"), Name = "teelöffel", Symbol = "TL" }, + new Unit { Id = Guid.Parse("24a91b89-3389-4465-89e4-2f70d2ea6fd7"), Name = "esslöffel", Symbol = "EL" }, + }; } } diff --git a/Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs b/Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs new file mode 100644 index 0000000..60e0775 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Category +{ + public class CategoryRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs b/Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs new file mode 100644 index 0000000..cfd14f4 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Category +{ + public interface ICategoryRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs b/Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs new file mode 100644 index 0000000..1f2259d --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs @@ -0,0 +1,9 @@ +namespace Francesco.Recipes.World.Data.Repository +{ + public class ErrorViewModel + { + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs b/Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs new file mode 100644 index 0000000..3292412 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Favorit +{ + public class FavoritRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs b/Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs new file mode 100644 index 0000000..1691bb0 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Favorit +{ + public interface IFavoritRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs b/Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs new file mode 100644 index 0000000..a24cb71 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs @@ -0,0 +1,17 @@ +namespace FrancescoRecipesWorld.Repositories +{ + using Francesco.Recipes.World.Models.BackendModels.Ingredient; + using Francesco.Recipes.World.Models.BackendModels.Recipe; + + public interface IIngredientRepository + { + Task CreateIngredientToRecipeAsync(int recipeId, string ingredientName); + Task UpdateIngredientAsync(Ingredient ingredient); + Task> GetIngredientsByRecipeIdAsync(Guid recipeId); + Task> GetRecipesByIngredientIdAsync(Guid ingredientId); + Task> GetIngredientsByNameAsync(string name); + Task RemoveIngredientFromRecipeAsync(Recipe recipe, Guid ingredientId); + Task GetIngredientByIdAsync(Guid ingredientId); + + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs b/Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs new file mode 100644 index 0000000..4d32131 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs @@ -0,0 +1,66 @@ +namespace FrancescoRecipesWorld.Repositories +{ + using Francesco.Recipes.World.Data; + using Francesco.Recipes.World.Models.BackendModels.Ingredient; + using Francesco.Recipes.World.Models.BackendModels.Recipe; + + public class IngredientRepository : IIngredientRepository + { + private readonly FrancescosRecipesWorldDbContext _context; + private readonly RecipeRepository _recipeRepository; + public IngredientRepository( + FrancescosRecipesWorldDbContext context, RecipeRepository recipeRepository) + { + _context = context; + _recipeRepository = recipeRepository; + } + + public async Task CreateIngredientToRecipeAsync(int recipeId, string ingredientName) + { + var recipe = await _context.Recipes.FindAsync(recipeId); + if (recipe == null) + { + throw new ArgumentException("Recipe not found", nameof(recipeId)); + } + + var newIngredient = new Ingredient + { + Name = ingredientName, + }; + _context.Ingredients.Add(newIngredient); + await _context.SaveChangesAsync(); + return newIngredient; + } + + public Task RemoveIngredientFromRecipeAsync(Recipe recipe, Guid ingredientId) + { + throw new NotImplementedException(); + } + + public Task> GetIngredientsByNameAsync(string name) + { + throw new NotImplementedException(); + } + + public Task> GetIngredientsByRecipeIdAsync(Guid recipeId) + { + throw new NotImplementedException(); + } + + public Task> GetRecipesByIngredientIdAsync(Guid ingredientId) + { + throw new NotImplementedException(); + } + + public Task UpdateIngredientAsync(Ingredient ingredient) + { + throw new NotImplementedException(); + } + + public async Task GetIngredientByIdAsync(Guid ingredientId) + { + var ingredient = await _context.Ingredients.FindAsync(ingredientId); + return ingredient ?? throw new InvalidDataException($"Address {ingredientId} not found."); + } + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs b/Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs new file mode 100644 index 0000000..9eb5c68 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Instruction +{ + public interface IInstructionsRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs b/Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs new file mode 100644 index 0000000..7306bb2 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Instruction +{ + public class InstructionsRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs b/Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs new file mode 100644 index 0000000..e8c1058 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.MediaFile +{ + public interface IMEdiaFileRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs b/Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs new file mode 100644 index 0000000..0c3490e --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.MediaFile +{ + public class MediaFileRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs b/Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs new file mode 100644 index 0000000..cd4e97b --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Recipe +{ + public interface IRecipeRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs b/Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs new file mode 100644 index 0000000..bd57464 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Recipe +{ + public class RecipeRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs b/Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs new file mode 100644 index 0000000..c7e3943 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.ShoppingLIst +{ + public interface IShoppingListRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs b/Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs new file mode 100644 index 0000000..5b0c2cb --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.ShoppingLIst +{ + public class ShoppingListRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs b/Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs new file mode 100644 index 0000000..443f0b1 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Unit +{ + public interface IUnitRepository + { + } +} diff --git a/Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs b/Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs new file mode 100644 index 0000000..ab66777 --- /dev/null +++ b/Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Unit +{ + public class UnitRepository + { + } +} diff --git a/Francesco.Recipes.World/Francesco.Recipes.World.csproj b/Francesco.Recipes.World/Francesco.Recipes.World.csproj index f9e0493..fff88d5 100644 --- a/Francesco.Recipes.World/Francesco.Recipes.World.csproj +++ b/Francesco.Recipes.World/Francesco.Recipes.World.csproj @@ -25,6 +25,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -38,4 +39,8 @@ + + + + diff --git a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs index 64934a2..5fa42d4 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs @@ -4,7 +4,7 @@ public class Category { public Guid Id { get; set; } - public string? Name { get; set; } + public string Name { get; set; } public virtual ICollection Recipes { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs index 902657a..e11bce3 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs @@ -7,8 +7,8 @@ namespace Francesco.Recipes.World.Models.BackendModels.Unit public class Unit { public Guid Id{ get; set; } - public string? Name { get; set; } - public string? Symbol { get; set; } + public string Name { get; set; } + public string Symbol { get; set; } public virtual ICollection RecipeIngredient { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Services/Category/CategoryService.cs b/Francesco.Recipes.World/Services/Category/CategoryService.cs new file mode 100644 index 0000000..df69cb8 --- /dev/null +++ b/Francesco.Recipes.World/Services/Category/CategoryService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Category +{ + public class CategoryService + { + } +} diff --git a/Francesco.Recipes.World/Services/Favorit/FavoritService.cs b/Francesco.Recipes.World/Services/Favorit/FavoritService.cs new file mode 100644 index 0000000..a37845b --- /dev/null +++ b/Francesco.Recipes.World/Services/Favorit/FavoritService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Favorit +{ + public class FavoritService + { + } +} diff --git a/Francesco.Recipes.World/Services/Ingredient/IngredientService.cs b/Francesco.Recipes.World/Services/Ingredient/IngredientService.cs new file mode 100644 index 0000000..8bdfb20 --- /dev/null +++ b/Francesco.Recipes.World/Services/Ingredient/IngredientService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Data.Repository.Ingredient +{ + public class IngredientService + { + } +} diff --git a/Francesco.Recipes.World/Services/Instruction/InstructionsService.cs b/Francesco.Recipes.World/Services/Instruction/InstructionsService.cs new file mode 100644 index 0000000..1b156dd --- /dev/null +++ b/Francesco.Recipes.World/Services/Instruction/InstructionsService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Repository.Instructions +{ + public class InstructionsService + { + } +} diff --git a/Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs b/Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs new file mode 100644 index 0000000..03c64e1 --- /dev/null +++ b/Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Repository.MediaFile +{ + public class MediaFileService + { + } +} diff --git a/Francesco.Recipes.World/Services/Recipe/RecipeService.cs b/Francesco.Recipes.World/Services/Recipe/RecipeService.cs new file mode 100644 index 0000000..f6bc9dc --- /dev/null +++ b/Francesco.Recipes.World/Services/Recipe/RecipeService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Repository.Recipe +{ + public class RecipeService + { + } +} diff --git a/Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs b/Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs new file mode 100644 index 0000000..84b68ee --- /dev/null +++ b/Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Repository.ShoppingLIst +{ + public class ShoppingListService + { + } +} diff --git a/Francesco.Recipes.World/Services/Unit/UnitService.cs b/Francesco.Recipes.World/Services/Unit/UnitService.cs new file mode 100644 index 0000000..82c2c8d --- /dev/null +++ b/Francesco.Recipes.World/Services/Unit/UnitService.cs @@ -0,0 +1,6 @@ +namespace Francesco.Recipes.World.Repository.Unit +{ + public class UnitService + { + } +} From d53729f798708f1a536d5c36e97f9510ed04dbe4 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 14:20:53 +0100 Subject: [PATCH 05/10] Corret Models Unit and Category --- .gitignore | 1 + .../Data/FrancescosRecipesWorldDbContext.cs | 125 +++++++++--------- .../Models/BackendModels/Category/Category.cs | 2 +- .../Models/BackendModels/Unit/Unit.cs | 4 +- 4 files changed, 66 insertions(+), 66 deletions(-) diff --git a/.gitignore b/.gitignore index 61101b4..ad9a362 100644 --- a/.gitignore +++ b/.gitignore @@ -397,3 +397,4 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml src/Recruitment.Tool.xml +/Francesco.Recipes.World/Migrations/20250304095839_AddFewNewBackendModels.Designer.cs diff --git a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs index e27bf78..0f6c858 100644 --- a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs +++ b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs @@ -1,8 +1,7 @@ -namespace Francesco.Recipes.World.Data; - -using System.Runtime.CompilerServices; -using Francesco.Recipes.World.Models.BackendModels; -using Francesco.Recipes.World.Models.BackendModels.Category; +namespace Francesco.Recipes.World.Data +{ + using Francesco.Recipes.World.Models.BackendModels; + using Francesco.Recipes.World.Models.BackendModels.Category; using Francesco.Recipes.World.Models.BackendModels.Favorit; using Francesco.Recipes.World.Models.BackendModels.Ingredient; using Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList; @@ -12,70 +11,69 @@ using Francesco.Recipes.World.Models.BackendModels.Category; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; using Francesco.Recipes.World.Models.BackendModels.Shoppinglist; using Francesco.Recipes.World.Models.BackendModels.Unit; -using Microsoft.EntityFrameworkCore; + using Microsoft.EntityFrameworkCore; -public class FrancescosRecipesWorldDbContext : DbContext -{ - public FrancescosRecipesWorldDbContext(DbContextOptions options) - : base(options) + public class FrancescosRecipesWorldDbContext : DbContext { - } - - public DbSet Categories => Set(); - public DbSet Ingredients => Set(); - public DbSet Instructions => Set(); - public DbSet Recipes => Set(); - public DbSet RecipeIngredients => Set(); - public DbSet Units => Set(); - public DbSet Favorits => Set(); - public DbSet IngredientsShoppingLists => Set(); - public DbSet ShoppingLists => Set(); - public DbSet MediaFiles => Set(); - public override Task SaveChangesAsync(CancellationToken cancellationToken = default) - { - foreach (var entry in ChangeTracker.Entries()) + public FrancescosRecipesWorldDbContext(DbContextOptions options) + : base(options) { - if (entry.Entity is ITimeStampedEntity timeStampedEntity) + } + + public DbSet Categories => Set(); + public DbSet Ingredients => Set(); + public DbSet Instructions => Set(); + public DbSet Recipes => Set(); + public DbSet RecipeIngredients => Set(); + public DbSet Units => Set(); + public DbSet Favorits => Set(); + public DbSet IngredientsShoppingLists => Set(); + public DbSet ShoppingLists => Set(); + public DbSet MediaFiles => Set(); + public override Task SaveChangesAsync(CancellationToken cancellationToken = default) + { + foreach (var entry in ChangeTracker.Entries()) { - switch (entry.State) + if (entry.Entity is ITimeStampedEntity timeStampedEntity) { - case EntityState.Added: - timeStampedEntity.CreatedAt = DateTime.UtcNow; - break; - case EntityState.Modified: - timeStampedEntity.ModifiedAt = DateTime.UtcNow; - break; + switch (entry.State) + { + case EntityState.Added: + timeStampedEntity.CreatedAt = DateTime.UtcNow; + break; + case EntityState.Modified: + timeStampedEntity.ModifiedAt = DateTime.UtcNow; + break; + } } } + + return base.SaveChangesAsync(cancellationToken); } - return base.SaveChangesAsync(cancellationToken); - } - protected override void OnModelCreating(ModelBuilder builder) - { - if (builder is null) + protected override void OnModelCreating(ModelBuilder builder) { - throw new ArgumentNullException(nameof(builder)); + ArgumentNullException.ThrowIfNull(builder); + + SeedData(builder); + + base.OnModelCreating(builder); } - SeedData(builder); - - base.OnModelCreating(builder); - } - - private static void SeedData(ModelBuilder modelBuilder) - { - modelBuilder.Entity() - .HasData(GetCategories()); - - modelBuilder.Entity() - .HasData(GetUnits()); - } - private static IEnumerable GetCategories() - { - return new List() + private static void SeedData(ModelBuilder modelBuilder) { - new Category { Id = Guid.Parse("b248244f-f21c-4555-a14d-5dd49a2717cf"), Name = "Vorspeisen & Snacks" }, + modelBuilder.Entity() + .HasData(GetCategories()); + + modelBuilder.Entity() + .HasData(GetUnits()); + } + + private static IEnumerable GetCategories() + { + return + [ + new Category { Id = Guid.Parse("b248244f-f21c-4555-a14d-5dd49a2717cf"), Name = "Vorspeisen & Snacks" }, new Category { Id = Guid.Parse("5186c5d6-5aff-4a6e-baf4-b61b72d889fe"), Name = "Erste Gänge" }, new Category { Id = Guid.Parse("abbc6bb0-97ea-49f5-b31e-6507eb784fd1"), Name = "Hauptgerichte" }, new Category { Id = Guid.Parse("90deec39-dcd0-422d-9018-ac8389e332e1"), Name = "Desserts & Süßspeisen" }, @@ -85,14 +83,14 @@ public class FrancescosRecipesWorldDbContext : DbContext new Category { Id = Guid.Parse("d332f88d-d241-48c5-a2f2-bfd124eada7e"), Name = "Soßen & Saucen" }, new Category { Id = Guid.Parse("23b1c740-e427-44f9-a6ea-d33d3f30f05a"), Name = "Marmeladen & Eingemachtes" }, new Category { Id = Guid.Parse("0a91a200-dc76-4e00-b38c-b38cab5b69d7"), Name = "Getränke" }, - }; - } + ]; + } - private static IEnumerable GetUnits() - { - return new List() + private static IEnumerable GetUnits() { - new Unit { Id = Guid.Parse("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), Name = "liter", Symbol = "l" }, + return + [ + new Unit { Id = Guid.Parse("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), Name = "liter", Symbol = "l" }, new Unit { Id = Guid.Parse("6c41f7e6-ca75-49cc-8541-cebd5a9c560b"), Name = "gramm", Symbol = "g" }, new Unit { Id = Guid.Parse("7e3d1b86-ac48-45d6-814e-d3492a86db1d"), Name = "kilogramm", Symbol = "kg" }, new Unit { Id = Guid.Parse("0c3648ec-4981-42c8-abf8-18bf1a2ff4c2"), Name = "stücke", Symbol = "stk" }, @@ -103,6 +101,7 @@ public class FrancescosRecipesWorldDbContext : DbContext new Unit { Id = Guid.Parse("66556e0e-eb2b-4bc3-9a56-135dd508ed09"), Name = "zehe", Symbol = "zehe" }, new Unit { Id = Guid.Parse("2e9894ac-14fa-43fd-ba07-35cdd8ebd461"), Name = "teelöffel", Symbol = "TL" }, new Unit { Id = Guid.Parse("24a91b89-3389-4465-89e4-2f70d2ea6fd7"), Name = "esslöffel", Symbol = "EL" }, - }; + ]; + } } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs index 5fa42d4..64934a2 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs @@ -4,7 +4,7 @@ public class Category { public Guid Id { get; set; } - public string Name { get; set; } + public string? Name { get; set; } public virtual ICollection Recipes { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs index e11bce3..902657a 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs @@ -7,8 +7,8 @@ namespace Francesco.Recipes.World.Models.BackendModels.Unit public class Unit { public Guid Id{ get; set; } - public string Name { get; set; } - public string Symbol { get; set; } + public string? Name { get; set; } + public string? Symbol { get; set; } public virtual ICollection RecipeIngredient { get; set; } = new List(); } } From 6125eb82ee492e4d7bdd66794a894bd4256d82b3 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 15:25:30 +0100 Subject: [PATCH 06/10] Correct Models --- .../Models/BackendModels/Category/Category.cs | 2 +- .../Models/BackendModels/Recipe/Recipe.cs | 47 +++++++++---------- .../Models/BackendModels/Unit/Unit.cs | 4 +- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs index 64934a2..5fa42d4 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs @@ -4,7 +4,7 @@ public class Category { public Guid Id { get; set; } - public string? Name { get; set; } + public string Name { get; set; } public virtual ICollection Recipes { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs index 68d180c..7d4e01e 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Recipe/Recipe.cs @@ -1,25 +1,24 @@ -namespace Francesco.Recipes.World.Models.BackendModels.Recipe -{ - using Francesco.Recipes.World.Models.BackendModels.Category; - using Francesco.Recipes.World.Models.BackendModels.Favorit; - using Francesco.Recipes.World.Models.BackendModels.Instruction; - using Francesco.Recipes.World.Models.BackendModels.MediaFile; - using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; +namespace Francesco.Recipes.World.Models.BackendModels.Recipe; - public class Recipe : ITimeStampedEntity - { - public Guid Id { get; set; } - public string Name { get; set; } - public string? Description { get; set; } - public Difficulty Difficulty { get; set; } - public int Servings { get; set; } - public TimeSpan PreparationTime { get; set; } - public TimeSpan CookingTime { get; set; } - public bool IsFavorite { get; set; } - public DateTime CreatedAt { get; set; } - public DateTime? ModifiedAt { get; set; } - public virtual ICollection RecipeIngredients { get; set; } = new List(); - public virtual ICollection Instructions { get; set; } = new List(); - public virtual ICollection MediaFiles { get; set; } = new List(); - public virtual Favorit Favorit { get; set; } = new(); - } +using Francesco.Recipes.World.Models.BackendModels.Favorit; +using Francesco.Recipes.World.Models.BackendModels.Instruction; +using Francesco.Recipes.World.Models.BackendModels.MediaFile; +using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; + +public class Recipe : ITimeStampedEntity +{ + public Guid Id { get; set; } + public string Name { get; set; } + public string? Description { get; set; } + public Difficulty Difficulty { get; set; } + public int Servings { get; set; } + public TimeSpan PreparationTime { get; set; } + public TimeSpan CookingTime { get; set; } + public bool IsFavorite { get; set; } + public DateTime CreatedAt { get; set; } + public DateTime? ModifiedAt { get; set; } + public virtual ICollection RecipeIngredients { get; set; } = new List(); + public virtual ICollection Instructions { get; set; } = new List(); + public virtual ICollection MediaFiles { get; set; } = new List(); + public virtual Favorit Favorit { get; set; } = new(); +} diff --git a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs index 902657a..e11bce3 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs @@ -7,8 +7,8 @@ namespace Francesco.Recipes.World.Models.BackendModels.Unit public class Unit { public Guid Id{ get; set; } - public string? Name { get; set; } - public string? Symbol { get; set; } + public string Name { get; set; } + public string Symbol { get; set; } public virtual ICollection RecipeIngredient { get; set; } = new List(); } } From dfd2d2ee3f6475cd1e732c659852470ee5b7e5a1 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 15:29:11 +0100 Subject: [PATCH 07/10] Delete unnecessary files --- .../Controllers/Favorit/FavoritController.cs | 6 -- .../Controllers/HomeController.cs | 32 --------- .../Ingredient/IngredientController.cs | 6 -- .../Instruction/InstructionController.cs | 6 -- .../MediaFile/MediaFilesController.cs | 9 --- .../Controllers/Recipe/RecipeController.cs | 6 -- .../ShoppingList/ShoppingLIstController.cs | 6 -- .../Repository/Category/CategoryRepository.cs | 6 -- .../Category/ICategoryRepository.cs | 6 -- .../Data/Repository/ErrorViewModel.cs | 9 --- .../Repository/Favorit/FavoritRepository.cs | 6 -- .../Repository/Favorit/IFavoritRepository.cs | 6 -- .../Ingredient/IIngredientRepository.cs | 17 ----- .../Ingredient/IngredientRepository.cs | 66 ------------------- .../Instruction/IInstructionsRepository.cs | 6 -- .../Instruction/InstructionsRepository.cs | 6 -- .../MediaFile/IMediaFileRepository.cs | 6 -- .../MediaFile/MediaFileRepository.cs | 6 -- .../Repository/Recipe/IRecipeRepository.cs | 6 -- .../Repository/Recipe/RecipeRepository.cs | 6 -- .../ShoppingLIst/IShoppingListRepository.cs | 6 -- .../ShoppingLIst/ShoppingListRepository.cs | 6 -- .../Data/Repository/Unit/IUnitRepository.cs | 6 -- .../Data/Repository/Unit/UnitRepository.cs | 6 -- .../Francesco.Recipes.World.csproj | 5 -- .../Services/Category/CategoryService.cs | 6 -- .../Services/Favorit/FavoritService.cs | 6 -- .../Services/Ingredient/IngredientService.cs | 6 -- .../Instruction/InstructionsService.cs | 6 -- .../Services/MediaFile/MediaFileService.cs | 6 -- .../Services/Recipe/RecipeService.cs | 6 -- .../ShoppingLIst/ShoppingListService.cs | 6 -- .../Services/Unit/UnitService.cs | 6 -- 33 files changed, 300 deletions(-) delete mode 100644 Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs delete mode 100644 Francesco.Recipes.World/Controllers/HomeController.cs delete mode 100644 Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs delete mode 100644 Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs delete mode 100644 Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs delete mode 100644 Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs delete mode 100644 Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs delete mode 100644 Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs delete mode 100644 Francesco.Recipes.World/Services/Category/CategoryService.cs delete mode 100644 Francesco.Recipes.World/Services/Favorit/FavoritService.cs delete mode 100644 Francesco.Recipes.World/Services/Ingredient/IngredientService.cs delete mode 100644 Francesco.Recipes.World/Services/Instruction/InstructionsService.cs delete mode 100644 Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs delete mode 100644 Francesco.Recipes.World/Services/Recipe/RecipeService.cs delete mode 100644 Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs delete mode 100644 Francesco.Recipes.World/Services/Unit/UnitService.cs diff --git a/Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs b/Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs deleted file mode 100644 index 7d66c1f..0000000 --- a/Francesco.Recipes.World/Controllers/Favorit/FavoritController.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Controllers.Favorit -{ - public class FavoritController - { - } -} diff --git a/Francesco.Recipes.World/Controllers/HomeController.cs b/Francesco.Recipes.World/Controllers/HomeController.cs deleted file mode 100644 index b5b0244..0000000 --- a/Francesco.Recipes.World/Controllers/HomeController.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace Francesco.Recipes.World.Controllers -{ - using System.Diagnostics; - using Francesco.Recipes.World.Models; - using Microsoft.AspNetCore.Mvc; - - public class HomeController : Controller - { - private readonly ILogger _logger; - - public HomeController(ILogger logger) - { - _logger = logger; - } - - public IActionResult Index() - { - return View(); - } - - public IActionResult Privacy() - { - return View(); - } - - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public IActionResult Error() - { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); - } - } -} diff --git a/Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs b/Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs deleted file mode 100644 index 187acb8..0000000 --- a/Francesco.Recipes.World/Controllers/Ingredient/IngredientController.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Controllers.Ingredient -{ - public class IngredientController - { - } -} diff --git a/Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs b/Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs deleted file mode 100644 index 17c9b8d..0000000 --- a/Francesco.Recipes.World/Controllers/Instruction/InstructionController.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Controllers.Instruction -{ - public class InstructionController - { - } -} diff --git a/Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs b/Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs deleted file mode 100644 index d17c5fd..0000000 --- a/Francesco.Recipes.World/Controllers/MediaFile/MediaFilesController.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Francesco.Recipes.World.Controllers.MediaFile -{ - using Microsoft.AspNetCore.Mvc; - - public class MediaFilesController : Controller - { - - } -} diff --git a/Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs b/Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs deleted file mode 100644 index a4b93ae..0000000 --- a/Francesco.Recipes.World/Controllers/Recipe/RecipeController.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Controllers.Recipe -{ - public class RecipeController - { - } -} diff --git a/Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs b/Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs deleted file mode 100644 index 03e77c6..0000000 --- a/Francesco.Recipes.World/Controllers/ShoppingList/ShoppingLIstController.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Controllers.ShoppingList -{ - public class ShoppingLIstController - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs b/Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs deleted file mode 100644 index 60e0775..0000000 --- a/Francesco.Recipes.World/Data/Repository/Category/CategoryRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Category -{ - public class CategoryRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs b/Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs deleted file mode 100644 index cfd14f4..0000000 --- a/Francesco.Recipes.World/Data/Repository/Category/ICategoryRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Category -{ - public interface ICategoryRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs b/Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs deleted file mode 100644 index 1f2259d..0000000 --- a/Francesco.Recipes.World/Data/Repository/ErrorViewModel.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository -{ - public class ErrorViewModel - { - public string? RequestId { get; set; } - - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs b/Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs deleted file mode 100644 index 3292412..0000000 --- a/Francesco.Recipes.World/Data/Repository/Favorit/FavoritRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Favorit -{ - public class FavoritRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs b/Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs deleted file mode 100644 index 1691bb0..0000000 --- a/Francesco.Recipes.World/Data/Repository/Favorit/IFavoritRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Favorit -{ - public interface IFavoritRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs b/Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs deleted file mode 100644 index a24cb71..0000000 --- a/Francesco.Recipes.World/Data/Repository/Ingredient/IIngredientRepository.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace FrancescoRecipesWorld.Repositories -{ - using Francesco.Recipes.World.Models.BackendModels.Ingredient; - using Francesco.Recipes.World.Models.BackendModels.Recipe; - - public interface IIngredientRepository - { - Task CreateIngredientToRecipeAsync(int recipeId, string ingredientName); - Task UpdateIngredientAsync(Ingredient ingredient); - Task> GetIngredientsByRecipeIdAsync(Guid recipeId); - Task> GetRecipesByIngredientIdAsync(Guid ingredientId); - Task> GetIngredientsByNameAsync(string name); - Task RemoveIngredientFromRecipeAsync(Recipe recipe, Guid ingredientId); - Task GetIngredientByIdAsync(Guid ingredientId); - - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs b/Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs deleted file mode 100644 index 4d32131..0000000 --- a/Francesco.Recipes.World/Data/Repository/Ingredient/IngredientRepository.cs +++ /dev/null @@ -1,66 +0,0 @@ -namespace FrancescoRecipesWorld.Repositories -{ - using Francesco.Recipes.World.Data; - using Francesco.Recipes.World.Models.BackendModels.Ingredient; - using Francesco.Recipes.World.Models.BackendModels.Recipe; - - public class IngredientRepository : IIngredientRepository - { - private readonly FrancescosRecipesWorldDbContext _context; - private readonly RecipeRepository _recipeRepository; - public IngredientRepository( - FrancescosRecipesWorldDbContext context, RecipeRepository recipeRepository) - { - _context = context; - _recipeRepository = recipeRepository; - } - - public async Task CreateIngredientToRecipeAsync(int recipeId, string ingredientName) - { - var recipe = await _context.Recipes.FindAsync(recipeId); - if (recipe == null) - { - throw new ArgumentException("Recipe not found", nameof(recipeId)); - } - - var newIngredient = new Ingredient - { - Name = ingredientName, - }; - _context.Ingredients.Add(newIngredient); - await _context.SaveChangesAsync(); - return newIngredient; - } - - public Task RemoveIngredientFromRecipeAsync(Recipe recipe, Guid ingredientId) - { - throw new NotImplementedException(); - } - - public Task> GetIngredientsByNameAsync(string name) - { - throw new NotImplementedException(); - } - - public Task> GetIngredientsByRecipeIdAsync(Guid recipeId) - { - throw new NotImplementedException(); - } - - public Task> GetRecipesByIngredientIdAsync(Guid ingredientId) - { - throw new NotImplementedException(); - } - - public Task UpdateIngredientAsync(Ingredient ingredient) - { - throw new NotImplementedException(); - } - - public async Task GetIngredientByIdAsync(Guid ingredientId) - { - var ingredient = await _context.Ingredients.FindAsync(ingredientId); - return ingredient ?? throw new InvalidDataException($"Address {ingredientId} not found."); - } - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs b/Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs deleted file mode 100644 index 9eb5c68..0000000 --- a/Francesco.Recipes.World/Data/Repository/Instruction/IInstructionsRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Instruction -{ - public interface IInstructionsRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs b/Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs deleted file mode 100644 index 7306bb2..0000000 --- a/Francesco.Recipes.World/Data/Repository/Instruction/InstructionsRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Instruction -{ - public class InstructionsRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs b/Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs deleted file mode 100644 index e8c1058..0000000 --- a/Francesco.Recipes.World/Data/Repository/MediaFile/IMediaFileRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.MediaFile -{ - public interface IMEdiaFileRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs b/Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs deleted file mode 100644 index 0c3490e..0000000 --- a/Francesco.Recipes.World/Data/Repository/MediaFile/MediaFileRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.MediaFile -{ - public class MediaFileRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs b/Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs deleted file mode 100644 index cd4e97b..0000000 --- a/Francesco.Recipes.World/Data/Repository/Recipe/IRecipeRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Recipe -{ - public interface IRecipeRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs b/Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs deleted file mode 100644 index bd57464..0000000 --- a/Francesco.Recipes.World/Data/Repository/Recipe/RecipeRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Recipe -{ - public class RecipeRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs b/Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs deleted file mode 100644 index c7e3943..0000000 --- a/Francesco.Recipes.World/Data/Repository/ShoppingLIst/IShoppingListRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.ShoppingLIst -{ - public interface IShoppingListRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs b/Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs deleted file mode 100644 index 5b0c2cb..0000000 --- a/Francesco.Recipes.World/Data/Repository/ShoppingLIst/ShoppingListRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.ShoppingLIst -{ - public class ShoppingListRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs b/Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs deleted file mode 100644 index 443f0b1..0000000 --- a/Francesco.Recipes.World/Data/Repository/Unit/IUnitRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Unit -{ - public interface IUnitRepository - { - } -} diff --git a/Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs b/Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs deleted file mode 100644 index ab66777..0000000 --- a/Francesco.Recipes.World/Data/Repository/Unit/UnitRepository.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Unit -{ - public class UnitRepository - { - } -} diff --git a/Francesco.Recipes.World/Francesco.Recipes.World.csproj b/Francesco.Recipes.World/Francesco.Recipes.World.csproj index fff88d5..f9e0493 100644 --- a/Francesco.Recipes.World/Francesco.Recipes.World.csproj +++ b/Francesco.Recipes.World/Francesco.Recipes.World.csproj @@ -25,7 +25,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -39,8 +38,4 @@ - - - - diff --git a/Francesco.Recipes.World/Services/Category/CategoryService.cs b/Francesco.Recipes.World/Services/Category/CategoryService.cs deleted file mode 100644 index df69cb8..0000000 --- a/Francesco.Recipes.World/Services/Category/CategoryService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Category -{ - public class CategoryService - { - } -} diff --git a/Francesco.Recipes.World/Services/Favorit/FavoritService.cs b/Francesco.Recipes.World/Services/Favorit/FavoritService.cs deleted file mode 100644 index a37845b..0000000 --- a/Francesco.Recipes.World/Services/Favorit/FavoritService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Favorit -{ - public class FavoritService - { - } -} diff --git a/Francesco.Recipes.World/Services/Ingredient/IngredientService.cs b/Francesco.Recipes.World/Services/Ingredient/IngredientService.cs deleted file mode 100644 index 8bdfb20..0000000 --- a/Francesco.Recipes.World/Services/Ingredient/IngredientService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Data.Repository.Ingredient -{ - public class IngredientService - { - } -} diff --git a/Francesco.Recipes.World/Services/Instruction/InstructionsService.cs b/Francesco.Recipes.World/Services/Instruction/InstructionsService.cs deleted file mode 100644 index 1b156dd..0000000 --- a/Francesco.Recipes.World/Services/Instruction/InstructionsService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Repository.Instructions -{ - public class InstructionsService - { - } -} diff --git a/Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs b/Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs deleted file mode 100644 index 03c64e1..0000000 --- a/Francesco.Recipes.World/Services/MediaFile/MediaFileService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Repository.MediaFile -{ - public class MediaFileService - { - } -} diff --git a/Francesco.Recipes.World/Services/Recipe/RecipeService.cs b/Francesco.Recipes.World/Services/Recipe/RecipeService.cs deleted file mode 100644 index f6bc9dc..0000000 --- a/Francesco.Recipes.World/Services/Recipe/RecipeService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Repository.Recipe -{ - public class RecipeService - { - } -} diff --git a/Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs b/Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs deleted file mode 100644 index 84b68ee..0000000 --- a/Francesco.Recipes.World/Services/ShoppingLIst/ShoppingListService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Repository.ShoppingLIst -{ - public class ShoppingListService - { - } -} diff --git a/Francesco.Recipes.World/Services/Unit/UnitService.cs b/Francesco.Recipes.World/Services/Unit/UnitService.cs deleted file mode 100644 index 82c2c8d..0000000 --- a/Francesco.Recipes.World/Services/Unit/UnitService.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Francesco.Recipes.World.Repository.Unit -{ - public class UnitService - { - } -} From a91ca743ab54059c12c076fa95788c740ddefcfe Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 15:45:14 +0100 Subject: [PATCH 08/10] Revert "Correct Models Unit and Category" This reverts commit 45702aa4f2fe4ea29a671744243d755370aeb384. --- .../Data/FrancescosRecipesWorldDbContext.cs | 21 ++++++++++++++++--- .../Models/BackendModels/Category/Category.cs | 2 +- .../Models/BackendModels/Unit/Unit.cs | 4 ++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs index 0f6c858..6a691b5 100644 --- a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs +++ b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs @@ -1,20 +1,22 @@ namespace Francesco.Recipes.World.Data { +<<<<<<< HEAD using Francesco.Recipes.World.Models.BackendModels; using Francesco.Recipes.World.Models.BackendModels.Category; using Francesco.Recipes.World.Models.BackendModels.Favorit; +======= + using Francesco.Recipes.World.Models.BackendModels.Category; +>>>>>>> parent of 45702aa (Correct Models Unit and Category) using Francesco.Recipes.World.Models.BackendModels.Ingredient; - using Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList; using Francesco.Recipes.World.Models.BackendModels.Instruction; - using Francesco.Recipes.World.Models.BackendModels.MediaFile; using Francesco.Recipes.World.Models.BackendModels.Recipe; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; - using Francesco.Recipes.World.Models.BackendModels.Shoppinglist; using Francesco.Recipes.World.Models.BackendModels.Unit; using Microsoft.EntityFrameworkCore; public class FrancescosRecipesWorldDbContext : DbContext { +<<<<<<< HEAD public FrancescosRecipesWorldDbContext(DbContextOptions options) : base(options) { @@ -103,5 +105,18 @@ new Unit { Id = Guid.Parse("24a91b89-3389-4465-89e4-2f70d2ea6fd7"), Name = "esslöffel", Symbol = "EL" }, ]; } +======= + public FrancescosRecipesWorldDbContext(DbContextOptions options) + : base(options) + { + } + + public DbSet Categories => Set(); + public DbSet Ingredients => Set(); + public DbSet Instructions => Set(); + public DbSet Recipes => Set(); + public DbSet RecipeIngredients => Set(); + public DbSet Units => Set(); +>>>>>>> parent of 45702aa (Correct Models Unit and Category) } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs index 5fa42d4..64934a2 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs @@ -4,7 +4,7 @@ public class Category { public Guid Id { get; set; } - public string Name { get; set; } + public string? Name { get; set; } public virtual ICollection Recipes { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs index e11bce3..902657a 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs @@ -7,8 +7,8 @@ namespace Francesco.Recipes.World.Models.BackendModels.Unit public class Unit { public Guid Id{ get; set; } - public string Name { get; set; } - public string Symbol { get; set; } + public string? Name { get; set; } + public string? Symbol { get; set; } public virtual ICollection RecipeIngredient { get; set; } = new List(); } } From c498e23a07d3715dbd7dfad6ce685d2732022310 Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Tue, 18 Mar 2025 16:14:01 +0100 Subject: [PATCH 09/10] Correct models unit and recipe and add a new migration --- .../Data/FrancescosRecipesWorldDbContext.cs | 21 +++------------- ...250318150949_InitialMIgration.Designer.cs} | 17 +++++++++++-- ....cs => 20250318150949_InitialMIgration.cs} | 24 ++++++++++--------- ...escosRecipesWorldDbContextModelSnapshot.cs | 13 ++++++++++ .../Models/BackendModels/Category/Category.cs | 2 +- .../Models/BackendModels/Unit/Unit.cs | 4 ++-- 6 files changed, 47 insertions(+), 34 deletions(-) rename Francesco.Recipes.World/Migrations/{20250318105823_InitialMigration.Designer.cs => 20250318150949_InitialMIgration.Designer.cs} (97%) rename Francesco.Recipes.World/Migrations/{20250318105823_InitialMigration.cs => 20250318150949_InitialMIgration.cs} (96%) diff --git a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs index 6a691b5..0f6c858 100644 --- a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs +++ b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs @@ -1,22 +1,20 @@ namespace Francesco.Recipes.World.Data { -<<<<<<< HEAD using Francesco.Recipes.World.Models.BackendModels; using Francesco.Recipes.World.Models.BackendModels.Category; using Francesco.Recipes.World.Models.BackendModels.Favorit; -======= - using Francesco.Recipes.World.Models.BackendModels.Category; ->>>>>>> parent of 45702aa (Correct Models Unit and Category) using Francesco.Recipes.World.Models.BackendModels.Ingredient; + using Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList; using Francesco.Recipes.World.Models.BackendModels.Instruction; + using Francesco.Recipes.World.Models.BackendModels.MediaFile; using Francesco.Recipes.World.Models.BackendModels.Recipe; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; + using Francesco.Recipes.World.Models.BackendModels.Shoppinglist; using Francesco.Recipes.World.Models.BackendModels.Unit; using Microsoft.EntityFrameworkCore; public class FrancescosRecipesWorldDbContext : DbContext { -<<<<<<< HEAD public FrancescosRecipesWorldDbContext(DbContextOptions options) : base(options) { @@ -105,18 +103,5 @@ new Unit { Id = Guid.Parse("24a91b89-3389-4465-89e4-2f70d2ea6fd7"), Name = "esslöffel", Symbol = "EL" }, ]; } -======= - public FrancescosRecipesWorldDbContext(DbContextOptions options) - : base(options) - { - } - - public DbSet Categories => Set(); - public DbSet Ingredients => Set(); - public DbSet Instructions => Set(); - public DbSet Recipes => Set(); - public DbSet RecipeIngredients => Set(); - public DbSet Units => Set(); ->>>>>>> parent of 45702aa (Correct Models Unit and Category) } } diff --git a/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.Designer.cs b/Francesco.Recipes.World/Migrations/20250318150949_InitialMIgration.Designer.cs similarity index 97% rename from Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.Designer.cs rename to Francesco.Recipes.World/Migrations/20250318150949_InitialMIgration.Designer.cs index ac67bcb..3f89444 100644 --- a/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.Designer.cs +++ b/Francesco.Recipes.World/Migrations/20250318150949_InitialMIgration.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace Francesco.Recipes.World.Migrations { [DbContext(typeof(FrancescosRecipesWorldDbContext))] - [Migration("20250318105823_InitialMigration")] - partial class InitialMigration + [Migration("20250318150949_InitialMIgration")] + partial class InitialMIgration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -32,6 +32,7 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -112,6 +113,7 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -147,9 +149,11 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Description") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Number") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("RecipeId") @@ -219,7 +223,11 @@ namespace Francesco.Recipes.World.Migrations b.Property("IsFavorite") .HasColumnType("bit"); + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("PreparationTime") @@ -275,6 +283,9 @@ namespace Francesco.Recipes.World.Migrations b.Property("CreatedAt") .HasColumnType("datetime2"); + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + b.HasKey("Id"); b.ToTable("ShoppingLists"); @@ -287,9 +298,11 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Symbol") + .IsRequired() .HasColumnType("nvarchar(max)"); b.HasKey("Id"); diff --git a/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.cs b/Francesco.Recipes.World/Migrations/20250318150949_InitialMIgration.cs similarity index 96% rename from Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.cs rename to Francesco.Recipes.World/Migrations/20250318150949_InitialMIgration.cs index 1e8d90d..2b14663 100644 --- a/Francesco.Recipes.World/Migrations/20250318105823_InitialMigration.cs +++ b/Francesco.Recipes.World/Migrations/20250318150949_InitialMIgration.cs @@ -8,12 +8,12 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace Francesco.Recipes.World.Migrations { /// - public partial class InitialMigration : Migration + public partial class InitialMIgration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { - if (migrationBuilder == null) + if (migrationBuilder is null) { throw new ArgumentNullException(nameof(migrationBuilder)); } @@ -22,7 +22,7 @@ namespace Francesco.Recipes.World.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: true) + Name = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -46,7 +46,7 @@ namespace Francesco.Recipes.World.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: true) + Name = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -58,7 +58,8 @@ namespace Francesco.Recipes.World.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - CreatedAt = table.Column(type: "datetime2", nullable: false) + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { @@ -70,8 +71,8 @@ namespace Francesco.Recipes.World.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: true), - Symbol = table.Column(type: "nvarchar(max)", nullable: true) + Name = table.Column(type: "nvarchar(max)", nullable: false), + Symbol = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { @@ -83,7 +84,7 @@ namespace Francesco.Recipes.World.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(max)", nullable: true), + Name = table.Column(type: "nvarchar(max)", nullable: false), Description = table.Column(type: "nvarchar(max)", nullable: true), Difficulty = table.Column(type: "int", nullable: false), Servings = table.Column(type: "int", nullable: false), @@ -91,6 +92,7 @@ namespace Francesco.Recipes.World.Migrations CookingTime = table.Column(type: "time", nullable: false), IsFavorite = table.Column(type: "bit", nullable: false), CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: true), FavoritId = table.Column(type: "uniqueidentifier", nullable: false), CategoryId = table.Column(type: "uniqueidentifier", nullable: true) }, @@ -140,8 +142,8 @@ namespace Francesco.Recipes.World.Migrations columns: table => new { Id = table.Column(type: "uniqueidentifier", nullable: false), - Description = table.Column(type: "nvarchar(max)", nullable: true), - Number = table.Column(type: "nvarchar(max)", nullable: true), + Description = table.Column(type: "nvarchar(max)", nullable: false), + Number = table.Column(type: "nvarchar(max)", nullable: false), RecipeId = table.Column(type: "uniqueidentifier", nullable: false) }, constraints: table => @@ -304,7 +306,7 @@ namespace Francesco.Recipes.World.Migrations /// protected override void Down(MigrationBuilder migrationBuilder) { - if (migrationBuilder == null) + if (migrationBuilder is null) { throw new ArgumentNullException(nameof(migrationBuilder)); } diff --git a/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs b/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs index 06d6ff4..e24e960 100644 --- a/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs +++ b/Francesco.Recipes.World/Migrations/FrancescosRecipesWorldDbContextModelSnapshot.cs @@ -29,6 +29,7 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -109,6 +110,7 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.HasKey("Id"); @@ -144,9 +146,11 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Description") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Number") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("RecipeId") @@ -216,7 +220,11 @@ namespace Francesco.Recipes.World.Migrations b.Property("IsFavorite") .HasColumnType("bit"); + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("PreparationTime") @@ -272,6 +280,9 @@ namespace Francesco.Recipes.World.Migrations b.Property("CreatedAt") .HasColumnType("datetime2"); + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + b.HasKey("Id"); b.ToTable("ShoppingLists"); @@ -284,9 +295,11 @@ namespace Francesco.Recipes.World.Migrations .HasColumnType("uniqueidentifier"); b.Property("Name") + .IsRequired() .HasColumnType("nvarchar(max)"); b.Property("Symbol") + .IsRequired() .HasColumnType("nvarchar(max)"); b.HasKey("Id"); diff --git a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs index 64934a2..5fa42d4 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Category/Category.cs @@ -4,7 +4,7 @@ public class Category { public Guid Id { get; set; } - public string? Name { get; set; } + public string Name { get; set; } public virtual ICollection Recipes { get; set; } = new List(); } } diff --git a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs index 902657a..e11bce3 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Unit/Unit.cs @@ -7,8 +7,8 @@ namespace Francesco.Recipes.World.Models.BackendModels.Unit public class Unit { public Guid Id{ get; set; } - public string? Name { get; set; } - public string? Symbol { get; set; } + public string Name { get; set; } + public string Symbol { get; set; } public virtual ICollection RecipeIngredient { get; set; } = new List(); } } From d1b8c3c7e0c24fba8e90a91c4fc2f550b467f1de Mon Sep 17 00:00:00 2001 From: Francesco D'Amico Date: Wed, 19 Mar 2025 10:52:01 +0100 Subject: [PATCH 10/10] Fix Formatting --- .../Data/FrancescosRecipesWorldDbContext.cs | 4 ++-- .../Models/BackendModels/Favorit/Favorit.cs | 1 + .../Models/BackendModels/Ingredient/Ingredient.cs | 1 - .../Models/BackendModels/Recipe/Difficulty.cs | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs index 0f6c858..5146867 100644 --- a/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs +++ b/Francesco.Recipes.World/Data/FrancescosRecipesWorldDbContext.cs @@ -73,7 +73,7 @@ { return [ - new Category { Id = Guid.Parse("b248244f-f21c-4555-a14d-5dd49a2717cf"), Name = "Vorspeisen & Snacks" }, + new Category { Id = Guid.Parse("b248244f-f21c-4555-a14d-5dd49a2717cf"), Name = "Vorspeisen & Snacks" }, new Category { Id = Guid.Parse("5186c5d6-5aff-4a6e-baf4-b61b72d889fe"), Name = "Erste Gänge" }, new Category { Id = Guid.Parse("abbc6bb0-97ea-49f5-b31e-6507eb784fd1"), Name = "Hauptgerichte" }, new Category { Id = Guid.Parse("90deec39-dcd0-422d-9018-ac8389e332e1"), Name = "Desserts & Süßspeisen" }, @@ -90,7 +90,7 @@ { return [ - new Unit { Id = Guid.Parse("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), Name = "liter", Symbol = "l" }, + new Unit { Id = Guid.Parse("62eb2c11-8768-46fb-9db0-c77f940bb4aa"), Name = "liter", Symbol = "l" }, new Unit { Id = Guid.Parse("6c41f7e6-ca75-49cc-8541-cebd5a9c560b"), Name = "gramm", Symbol = "g" }, new Unit { Id = Guid.Parse("7e3d1b86-ac48-45d6-814e-d3492a86db1d"), Name = "kilogramm", Symbol = "kg" }, new Unit { Id = Guid.Parse("0c3648ec-4981-42c8-abf8-18bf1a2ff4c2"), Name = "stücke", Symbol = "stk" }, diff --git a/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs b/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs index 538dd99..65b9aa9 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Favorit/Favorit.cs @@ -1,6 +1,7 @@ namespace Francesco.Recipes.World.Models.BackendModels.Favorit { using Francesco.Recipes.World.Models.BackendModels.Recipe; + public class Favorit { public Guid Id { get; set; } diff --git a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs index f8bf8eb..2a3e4d4 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Ingredient/Ingredient.cs @@ -2,7 +2,6 @@ { using Francesco.Recipes.World.Models.BackendModels.IngredientShoppingList; using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient; - using Francesco.Recipes.World.Models.BackendModels.Unit; public class Ingredient { diff --git a/Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs b/Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs index 3c3036e..91d20a0 100644 --- a/Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs +++ b/Francesco.Recipes.World/Models/BackendModels/Recipe/Difficulty.cs @@ -6,7 +6,6 @@ Easy = 2, Medium = 3, Hard = 4, - Expert = 5 + Expert = 5, } - }