summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorPaweł Bernaciak <pawelbernaciak@zohomail.eu>2023-10-25 20:28:34 +0200
committerPaweł Bernaciak <pawelbernaciak@zohomail.eu>2023-10-25 20:28:34 +0200
commit2e86ace4593d32a2cb1a4be9a758911ff25e4a89 (patch)
tree33582ae0ef03f6a1556f950a43004bba6c1ee0f2 /backend
parent68e4282555a55f429320b80f09f609970dc76e92 (diff)
Model fixes
Diffstat (limited to 'backend')
-rw-r--r--backend/Elements.Backend/Controllers/ElementController.cs8
-rw-r--r--backend/Elements.Backend/Controllers/SuggestionController.cs4
-rw-r--r--backend/Elements.Data/ApplicationDbContext.cs4
-rw-r--r--backend/Elements.Data/Migrations/20231024192803_Add creation dates.Designer.cs299
-rw-r--r--backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs201
-rw-r--r--backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs40
-rw-r--r--backend/Elements.Data/Models/Element.cs1
-rw-r--r--backend/Elements.Data/Models/Recipe.cs10
-rw-r--r--backend/Elements.Data/Models/Suggestion.cs1
9 files changed, 545 insertions, 23 deletions
diff --git a/backend/Elements.Backend/Controllers/ElementController.cs b/backend/Elements.Backend/Controllers/ElementController.cs
index 890f614..2f57514 100644
--- a/backend/Elements.Backend/Controllers/ElementController.cs
+++ b/backend/Elements.Backend/Controllers/ElementController.cs
@@ -51,13 +51,13 @@ public class ElementController : ControllerBase
if (!firstExists || !secondExists)
return BadRequest();
- Recipe? recipe = await _dbContext.Recipes.Include(r => r.Result).FirstOrDefaultAsync(r =>
- (r.FirstIngredient.Id == firstElementId && r.SecondIngredient.Id == secondElementId) ||
- (r.FirstIngredient.Id == secondElementId && r.SecondIngredient.Id == firstElementId));
+ Recipe? recipe = await _dbContext.Recipes.Include(r => r.ResultElement).FirstOrDefaultAsync(r =>
+ (r.FirstElementId == firstElementId && r.SecondElementId == secondElementId) ||
+ (r.FirstElementId == secondElementId && r.SecondElementId == firstElementId));
if (recipe == null)
return NotFound();
var serializeOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
- return Ok(JsonSerializer.Serialize(recipe.Result, serializeOptions));
+ return Ok(JsonSerializer.Serialize(recipe.ResultElement, serializeOptions));
}
} \ No newline at end of file
diff --git a/backend/Elements.Backend/Controllers/SuggestionController.cs b/backend/Elements.Backend/Controllers/SuggestionController.cs
index 77a3944..040b19b 100644
--- a/backend/Elements.Backend/Controllers/SuggestionController.cs
+++ b/backend/Elements.Backend/Controllers/SuggestionController.cs
@@ -112,16 +112,18 @@ public class SuggestionController : ControllerBase
if (currentUserId == null)
return StatusCode(StatusCodes.Status500InternalServerError);
+ //User already suggested something
if (await _dbContext.Suggestions.AnyAsync(s => s.UserId.ToString() == currentUserId))
return BadRequest();
Suggestion newSuggestion = new()
{
+ CreationDate = DateTime.UtcNow,
Name = suggestion.Name,
Icon = ConvertBitmapToPng(Convert.FromBase64String(suggestion.IconBitmap)),
FirstElementId = suggestion.FirstElementId,
SecondElementId = suggestion.SecondElementId,
- VotingEnd = DateTime.UtcNow + TimeSpan.FromMinutes(1),
+ VotingEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10),
UserId = int.Parse(currentUserId)
};
await _dbContext.Suggestions.AddAsync(newSuggestion);
diff --git a/backend/Elements.Data/ApplicationDbContext.cs b/backend/Elements.Data/ApplicationDbContext.cs
index d971b4e..460e730 100644
--- a/backend/Elements.Data/ApplicationDbContext.cs
+++ b/backend/Elements.Data/ApplicationDbContext.cs
@@ -36,6 +36,7 @@ public class ApplicationDbContext : DbContext
new Element()
{
Id = 1,
+ CreationDate = DateTime.UtcNow,
Name = "Fire",
UserId = 1,
State = ElementState.HasIcon,
@@ -44,6 +45,7 @@ public class ApplicationDbContext : DbContext
new Element()
{
Id = 2,
+ CreationDate = DateTime.UtcNow,
Name = "Water",
UserId = 1,
State = ElementState.HasIcon,
@@ -52,6 +54,7 @@ public class ApplicationDbContext : DbContext
new Element()
{
Id = 3,
+ CreationDate = DateTime.UtcNow,
Name = "Air",
UserId = 1,
State = ElementState.HasIcon,
@@ -60,6 +63,7 @@ public class ApplicationDbContext : DbContext
new Element()
{
Id = 4,
+ CreationDate = DateTime.UtcNow,
Name = "Ground",
UserId = 1,
State = ElementState.HasIcon,
diff --git a/backend/Elements.Data/Migrations/20231024192803_Add creation dates.Designer.cs b/backend/Elements.Data/Migrations/20231024192803_Add creation dates.Designer.cs
new file mode 100644
index 0000000..ae7fa06
--- /dev/null
+++ b/backend/Elements.Data/Migrations/20231024192803_Add creation dates.Designer.cs
@@ -0,0 +1,299 @@
+// <auto-generated />
+using System;
+using Elements.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace Elements.Data.Migrations
+{
+ [DbContext(typeof(ApplicationDbContext))]
+ [Migration("20231024192803_Add creation dates")]
+ partial class Addcreationdates
+ {
+ /// <inheritdoc />
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "7.0.12");
+
+ modelBuilder.Entity("Elements.Data.Models.Element", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("CreationDate")
+ .HasColumnType("TEXT");
+
+ b.Property<byte[]>("IconPng")
+ .IsRequired()
+ .HasColumnType("BLOB");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<int>("State")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Elements");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(1750),
+ IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 249, 95, 224, 252, 159, 129, 2, 192, 194, 64, 33, 24, 53, 96, 212, 128, 81, 3, 6, 139, 1, 0, 119, 65, 2, 242, 233, 108, 215, 141, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
+ Name = "Fire",
+ State = 1,
+ UserId = 1
+ },
+ new
+ {
+ Id = 2,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(2880),
+ IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 81, 156, 246, 249, 63, 3, 5, 128, 133, 129, 66, 48, 106, 192, 168, 1, 163, 6, 12, 22, 3, 0, 85, 67, 2, 234, 36, 203, 134, 16, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
+ Name = "Water",
+ State = 1,
+ UserId = 1
+ },
+ new
+ {
+ Id = 3,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3350),
+ IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 30, 73, 68, 65, 84, 120, 156, 99, 217, 125, 239, 247, 127, 6, 10, 0, 11, 3, 133, 96, 212, 128, 81, 3, 70, 13, 24, 44, 6, 0, 0, 10, 221, 3, 212, 197, 89, 182, 174, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
+ Name = "Air",
+ State = 1,
+ UserId = 1
+ },
+ new
+ {
+ Id = 4,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3790),
+ IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 137, 117, 48, 255, 207, 64, 1, 96, 97, 160, 16, 140, 26, 48, 106, 192, 168, 1, 131, 197, 0, 0, 242, 75, 2, 20, 1, 55, 196, 168, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
+ Name = "Ground",
+ State = 1,
+ UserId = 1
+ });
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Recipe", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("FirstElementId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("ResultElementId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SecondElementId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FirstElementId");
+
+ b.HasIndex("ResultElementId");
+
+ b.HasIndex("SecondElementId");
+
+ b.ToTable("Recipes");
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Suggestion", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("CreationDate")
+ .HasColumnType("TEXT");
+
+ b.Property<int>("FirstElementId")
+ .HasColumnType("INTEGER");
+
+ b.Property<byte[]>("Icon")
+ .IsRequired()
+ .HasColumnType("BLOB");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<int>("SecondElementId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property<DateTime>("VotingEnd")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("FirstElementId");
+
+ b.HasIndex("SecondElementId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Suggestions");
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.User", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<string>("GoogleId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property<string>("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Users");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ GoogleId = "",
+ Name = "Elements"
+ });
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Vote", b =>
+ {
+ b.Property<int>("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("SuggestionId")
+ .HasColumnType("INTEGER");
+
+ b.Property<int>("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SuggestionId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Votes");
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Element", b =>
+ {
+ b.HasOne("Elements.Data.Models.User", "User")
+ .WithMany("Elements")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Recipe", b =>
+ {
+ b.HasOne("Elements.Data.Models.Element", "FirstElement")
+ .WithMany()
+ .HasForeignKey("FirstElementId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Elements.Data.Models.Element", "ResultElement")
+ .WithMany()
+ .HasForeignKey("ResultElementId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Elements.Data.Models.Element", "SecondElement")
+ .WithMany()
+ .HasForeignKey("SecondElementId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("FirstElement");
+
+ b.Navigation("ResultElement");
+
+ b.Navigation("SecondElement");
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Suggestion", b =>
+ {
+ b.HasOne("Elements.Data.Models.Element", "FirstElement")
+ .WithMany()
+ .HasForeignKey("FirstElementId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Elements.Data.Models.Element", "SecondElement")
+ .WithMany()
+ .HasForeignKey("SecondElementId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Elements.Data.Models.User", null)
+ .WithMany("Suggestions")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("FirstElement");
+
+ b.Navigation("SecondElement");
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Vote", b =>
+ {
+ b.HasOne("Elements.Data.Models.Suggestion", null)
+ .WithMany("Votes")
+ .HasForeignKey("SuggestionId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Elements.Data.Models.User", null)
+ .WithMany("Votes")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.Suggestion", b =>
+ {
+ b.Navigation("Votes");
+ });
+
+ modelBuilder.Entity("Elements.Data.Models.User", b =>
+ {
+ b.Navigation("Elements");
+
+ b.Navigation("Suggestions");
+
+ b.Navigation("Votes");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs b/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs
new file mode 100644
index 0000000..3612108
--- /dev/null
+++ b/backend/Elements.Data/Migrations/20231024192803_Add creation dates.cs
@@ -0,0 +1,201 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace Elements.Data.Migrations
+{
+ /// <inheritdoc />
+ public partial class Addcreationdates : Migration
+ {
+ /// <inheritdoc />
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Recipes_Elements_FirstIngredientId",
+ table: "Recipes");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Recipes_Elements_ResultId",
+ table: "Recipes");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Recipes_Elements_SecondIngredientId",
+ table: "Recipes");
+
+ migrationBuilder.RenameColumn(
+ name: "SecondIngredientId",
+ table: "Recipes",
+ newName: "SecondElementId");
+
+ migrationBuilder.RenameColumn(
+ name: "ResultId",
+ table: "Recipes",
+ newName: "ResultElementId");
+
+ migrationBuilder.RenameColumn(
+ name: "FirstIngredientId",
+ table: "Recipes",
+ newName: "FirstElementId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Recipes_SecondIngredientId",
+ table: "Recipes",
+ newName: "IX_Recipes_SecondElementId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Recipes_ResultId",
+ table: "Recipes",
+ newName: "IX_Recipes_ResultElementId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Recipes_FirstIngredientId",
+ table: "Recipes",
+ newName: "IX_Recipes_FirstElementId");
+
+ migrationBuilder.AddColumn<DateTime>(
+ name: "CreationDate",
+ table: "Suggestions",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.AddColumn<DateTime>(
+ name: "CreationDate",
+ table: "Elements",
+ type: "TEXT",
+ nullable: false,
+ defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
+
+ migrationBuilder.UpdateData(
+ table: "Elements",
+ keyColumn: "Id",
+ keyValue: 1,
+ column: "CreationDate",
+ value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(1750));
+
+ migrationBuilder.UpdateData(
+ table: "Elements",
+ keyColumn: "Id",
+ keyValue: 2,
+ column: "CreationDate",
+ value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(2880));
+
+ migrationBuilder.UpdateData(
+ table: "Elements",
+ keyColumn: "Id",
+ keyValue: 3,
+ column: "CreationDate",
+ value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3350));
+
+ migrationBuilder.UpdateData(
+ table: "Elements",
+ keyColumn: "Id",
+ keyValue: 4,
+ column: "CreationDate",
+ value: new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3790));
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Recipes_Elements_FirstElementId",
+ table: "Recipes",
+ column: "FirstElementId",
+ principalTable: "Elements",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Recipes_Elements_ResultElementId",
+ table: "Recipes",
+ column: "ResultElementId",
+ principalTable: "Elements",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Recipes_Elements_SecondElementId",
+ table: "Recipes",
+ column: "SecondElementId",
+ principalTable: "Elements",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ /// <inheritdoc />
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Recipes_Elements_FirstElementId",
+ table: "Recipes");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Recipes_Elements_ResultElementId",
+ table: "Recipes");
+
+ migrationBuilder.DropForeignKey(
+ name: "FK_Recipes_Elements_SecondElementId",
+ table: "Recipes");
+
+ migrationBuilder.DropColumn(
+ name: "CreationDate",
+ table: "Suggestions");
+
+ migrationBuilder.DropColumn(
+ name: "CreationDate",
+ table: "Elements");
+
+ migrationBuilder.RenameColumn(
+ name: "SecondElementId",
+ table: "Recipes",
+ newName: "SecondIngredientId");
+
+ migrationBuilder.RenameColumn(
+ name: "ResultElementId",
+ table: "Recipes",
+ newName: "ResultId");
+
+ migrationBuilder.RenameColumn(
+ name: "FirstElementId",
+ table: "Recipes",
+ newName: "FirstIngredientId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Recipes_SecondElementId",
+ table: "Recipes",
+ newName: "IX_Recipes_SecondIngredientId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Recipes_ResultElementId",
+ table: "Recipes",
+ newName: "IX_Recipes_ResultId");
+
+ migrationBuilder.RenameIndex(
+ name: "IX_Recipes_FirstElementId",
+ table: "Recipes",
+ newName: "IX_Recipes_FirstIngredientId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Recipes_Elements_FirstIngredientId",
+ table: "Recipes",
+ column: "FirstIngredientId",
+ principalTable: "Elements",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Recipes_Elements_ResultId",
+ table: "Recipes",
+ column: "ResultId",
+ principalTable: "Elements",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Recipes_Elements_SecondIngredientId",
+ table: "Recipes",
+ column: "SecondIngredientId",
+ principalTable: "Elements",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+ }
+}
diff --git a/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs b/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs
index 5964a6c..7b88425 100644
--- a/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs
+++ b/backend/Elements.Data/Migrations/ApplicationDbContextModelSnapshot.cs
@@ -23,6 +23,9 @@ namespace Elements.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
+ b.Property<DateTime>("CreationDate")
+ .HasColumnType("TEXT");
+
b.Property<byte[]>("IconPng")
.IsRequired()
.HasColumnType("BLOB");
@@ -47,6 +50,7 @@ namespace Elements.Data.Migrations
new
{
Id = 1,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(1750),
IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 249, 95, 224, 252, 159, 129, 2, 192, 194, 64, 33, 24, 53, 96, 212, 128, 81, 3, 6, 139, 1, 0, 119, 65, 2, 242, 233, 108, 215, 141, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
Name = "Fire",
State = 1,
@@ -55,6 +59,7 @@ namespace Elements.Data.Migrations
new
{
Id = 2,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(2880),
IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 81, 156, 246, 249, 63, 3, 5, 128, 133, 129, 66, 48, 106, 192, 168, 1, 163, 6, 12, 22, 3, 0, 85, 67, 2, 234, 36, 203, 134, 16, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
Name = "Water",
State = 1,
@@ -63,6 +68,7 @@ namespace Elements.Data.Migrations
new
{
Id = 3,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3350),
IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 30, 73, 68, 65, 84, 120, 156, 99, 217, 125, 239, 247, 127, 6, 10, 0, 11, 3, 133, 96, 212, 128, 81, 3, 70, 13, 24, 44, 6, 0, 0, 10, 221, 3, 212, 197, 89, 182, 174, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
Name = "Air",
State = 1,
@@ -71,6 +77,7 @@ namespace Elements.Data.Migrations
new
{
Id = 4,
+ CreationDate = new DateTime(2023, 10, 24, 19, 28, 3, 290, DateTimeKind.Utc).AddTicks(3790),
IconPng = new byte[] { 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0, 0, 16, 0, 0, 0, 16, 8, 6, 0, 0, 0, 31, 243, 255, 97, 0, 0, 0, 9, 112, 72, 89, 115, 0, 0, 14, 196, 0, 0, 14, 196, 1, 149, 43, 14, 27, 0, 0, 0, 29, 73, 68, 65, 84, 120, 156, 99, 137, 117, 48, 255, 207, 64, 1, 96, 97, 160, 16, 140, 26, 48, 106, 192, 168, 1, 131, 197, 0, 0, 242, 75, 2, 20, 1, 55, 196, 168, 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130 },
Name = "Ground",
State = 1,
@@ -84,22 +91,22 @@ namespace Elements.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
- b.Property<int>("FirstIngredientId")
+ b.Property<int>("FirstElementId")
.HasColumnType("INTEGER");
- b.Property<int>("ResultId")
+ b.Property<int>("ResultElementId")
.HasColumnType("INTEGER");
- b.Property<int>("SecondIngredientId")
+ b.Property<int>("SecondElementId")
.HasColumnType("INTEGER");
b.HasKey("Id");
- b.HasIndex("FirstIngredientId");
+ b.HasIndex("FirstElementId");
- b.HasIndex("ResultId");
+ b.HasIndex("ResultElementId");
- b.HasIndex("SecondIngredientId");
+ b.HasIndex("SecondElementId");
b.ToTable("Recipes");
});
@@ -110,6 +117,9 @@ namespace Elements.Data.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
+ b.Property<DateTime>("CreationDate")
+ .HasColumnType("TEXT");
+
b.Property<int>("FirstElementId")
.HasColumnType("INTEGER");
@@ -202,29 +212,29 @@ namespace Elements.Data.Migrations
modelBuilder.Entity("Elements.Data.Models.Recipe", b =>
{
- b.HasOne("Elements.Data.Models.Element", "FirstIngredient")
+ b.HasOne("Elements.Data.Models.Element", "FirstElement")
.WithMany()
- .HasForeignKey("FirstIngredientId")
+ .HasForeignKey("FirstElementId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.HasOne("Elements.Data.Models.Element", "Result")
+ b.HasOne("Elements.Data.Models.Element", "ResultElement")
.WithMany()
- .HasForeignKey("ResultId")
+ .HasForeignKey("ResultElementId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.HasOne("Elements.Data.Models.Element", "SecondIngredient")
+ b.HasOne("Elements.Data.Models.Element", "SecondElement")
.WithMany()
- .HasForeignKey("SecondIngredientId")
+ .HasForeignKey("SecondElementId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
- b.Navigation("FirstIngredient");
+ b.Navigation("FirstElement");
- b.Navigation("Result");
+ b.Navigation("ResultElement");
- b.Navigation("SecondIngredient");
+ b.Navigation("SecondElement");
});
modelBuilder.Entity("Elements.Data.Models.Suggestion", b =>
diff --git a/backend/Elements.Data/Models/Element.cs b/backend/Elements.Data/Models/Element.cs
index 273c83d..774b7ee 100644
--- a/backend/Elements.Data/Models/Element.cs
+++ b/backend/Elements.Data/Models/Element.cs
@@ -10,6 +10,7 @@ public enum ElementState {
public class Element {
public int Id {get; set;}
+ public required DateTime CreationDate { get; init; }
public required int UserId { get; init; }
public required string Name {get; init;}
public required ElementState State {get; init;}
diff --git a/backend/Elements.Data/Models/Recipe.cs b/backend/Elements.Data/Models/Recipe.cs
index a942561..6fdcd78 100644
--- a/backend/Elements.Data/Models/Recipe.cs
+++ b/backend/Elements.Data/Models/Recipe.cs
@@ -3,7 +3,11 @@ namespace Elements.Data.Models;
public class Recipe
{
public int Id { get; set; }
- public required Element FirstIngredient { get; init; }
- public required Element SecondIngredient { get; set; }
- public required Element Result { get; set; }
+ public required int FirstElementId { get; init; }
+ public required int SecondElementId { get; init; }
+ public required int ResultElementId { get; init; }
+
+ public Element FirstElement { get; set; } = null!;
+ public Element SecondElement { get; set; } = null!;
+ public Element ResultElement { get; set; } = null!;
} \ No newline at end of file
diff --git a/backend/Elements.Data/Models/Suggestion.cs b/backend/Elements.Data/Models/Suggestion.cs
index bd936a4..7f30761 100644
--- a/backend/Elements.Data/Models/Suggestion.cs
+++ b/backend/Elements.Data/Models/Suggestion.cs
@@ -3,6 +3,7 @@ namespace Elements.Data.Models;
public class Suggestion
{
public int Id { get; set; }
+ public required DateTime CreationDate { get; init; }
public required string Name { get; init; }
public required byte[] Icon { get; init; }
public required int FirstElementId { get; init; }