diff --git a/.idea/.idea.DreamsCaster/.idea/efCoreCommonOptions.xml b/.idea/.idea.DreamsCaster/.idea/efCoreCommonOptions.xml
new file mode 100644
index 0000000..b786893
--- /dev/null
+++ b/.idea/.idea.DreamsCaster/.idea/efCoreCommonOptions.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DreamsCaster/AppDbContext.cs b/DreamsCaster/AppDbContext.cs
index 649848f..23ca5ad 100644
--- a/DreamsCaster/AppDbContext.cs
+++ b/DreamsCaster/AppDbContext.cs
@@ -1,3 +1,4 @@
+using System.ComponentModel.DataAnnotations.Schema;
using DreamsCaster.Models;
using Microsoft.EntityFrameworkCore;
using Console = DreamsCaster.Models.Console;
@@ -6,8 +7,43 @@ namespace DreamsCaster;
public class AppDbContext : DbContext
{
- public DbSet Games;
- public DbSet Consoles;
+ public DbSet Games { get; set; }
+ public DbSet Consoles { get; set; }
+
+ public DbSet Developers { get; set; }
+ public DbSet Publishers { get; set; }
+ public DbSet Manufacturers { get; set; }
+ public DbSet Releases { get; set; }
+
+ public DbSet> GamesMetaData { get; set; }
+ public DbSet> ConsolesMetaData { get; set; }
+ public DbSet> DevelopersMetaData { get; set; }
+ public DbSet> PublishersMetaData { get; set; }
+ public DbSet> ManufacturersMetaData { get; set; }
+
+ public AppDbContext() : base() { }
+
+ public AppDbContext(DbContextOptions options) : base(options) { }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ ConfigureMetaDataFor(modelBuilder);
+ ConfigureMetaDataFor(modelBuilder);
+ ConfigureMetaDataFor(modelBuilder);
+ ConfigureMetaDataFor(modelBuilder);
+ ConfigureMetaDataFor(modelBuilder);
+ }
+
+ void ConfigureMetaDataFor(ModelBuilder modelBuilder) where T : MetaDataContainer
+ {
+ modelBuilder.Entity()
+ .HasOne(a => a.Data)
+ .WithOne(b => b.Owner)
+ .HasForeignKey>(c => c.OwnerId)
+ .OnDelete(DeleteBehavior.Cascade);
+ }
}
public static class DatabaseExtensions
diff --git a/DreamsCaster/AppDbContextFactory.cs b/DreamsCaster/AppDbContextFactory.cs
new file mode 100644
index 0000000..05a1525
--- /dev/null
+++ b/DreamsCaster/AppDbContextFactory.cs
@@ -0,0 +1,34 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Design;
+
+namespace DreamsCaster;
+
+public class AppDbContextFactory : IDesignTimeDbContextFactory {
+ public AppDbContext CreateDbContext (ILoggerFactory? loggerFactory, IConfiguration config) {
+ var connStr = config.GetConnectionString ("Database");
+
+ var serverVersion = ServerVersion.AutoDetect (connStr);
+
+ var optionsBuilder = new DbContextOptionsBuilder ()
+#if VERBOSE
+ .UseLoggerFactory (loggerFactory)
+#endif
+ .UseMySql (
+ connStr,
+ serverVersion,
+ x => {
+ x.EnableRetryOnFailure ();
+ });
+
+ return new AppDbContext (optionsBuilder.Options);
+ }
+
+ public AppDbContext CreateDbContext (string[] args = null) {
+ var config = new ConfigurationBuilder ()
+ .SetBasePath (AppDomain.CurrentDomain.BaseDirectory)
+ .AddJsonFile ("appsettings.json")
+ .Build ();
+
+ return CreateDbContext (null, config);
+ }
+}
\ No newline at end of file
diff --git a/DreamsCaster/Controllers/ConsoleController.cs b/DreamsCaster/Controllers/ConsoleController.cs
index e614dd6..590742c 100644
--- a/DreamsCaster/Controllers/ConsoleController.cs
+++ b/DreamsCaster/Controllers/ConsoleController.cs
@@ -1,4 +1,3 @@
-using DreamsCaster.Helpers;
using DreamsCaster.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -12,17 +11,22 @@ public class ConsoleController : ControllerBase
{
public AppDbContext Database { get; set; }
- [HttpGet]
- public IActionResult Get([FromQuery] Guid consoleId)
+ public ConsoleController(AppDbContext dbContext)
{
- if (!Database.Consoles.TryGet(consoleId, out Game game)) return NotFound();
+ Database = dbContext;
+ }
+
+ [HttpGet("{consoleId:guid}")]
+ public IActionResult Get([FromRoute] Guid consoleId)
+ {
+ if (!Database.Consoles.TryGet(consoleId, out var game)) return NotFound();
return Ok(game);
}
- [HttpGet]
- [Authorize]
- public async Task DeleteAsync([FromQuery] Guid consoleId)
+ [HttpDelete("{consoleId:guid}")]
+ //[Authorize]
+ public async Task DeleteAsync([FromRoute] Guid consoleId)
{
if (!Database.Games.TryGet(consoleId, out var game)) return NotFound();
@@ -40,45 +44,42 @@ public class ConsoleController : ControllerBase
return Ok();
}
- [HttpPatch]
- [Authorize]
- public async Task PatchAsync([FromQuery] Guid consoleId)
+ [HttpPatch("{consoleId:guid}")]
+ //[Authorize]
+ public async Task PatchAsync([FromRoute] Guid consoleId, [FromBody] PatchInfo newData)
{
+ if (!Database.Games.TryGet(consoleId, out Game game)) return NotFound();
+
+ if (newData.Name.HasValue) game.Name = newData.Name;
+ if (newData.Description.HasValue) game.Data.Description = newData.Description;
+ if (newData.CoverPhoto.HasValue) game.Data.CoverPhoto = newData.CoverPhoto;
+ await Database.SaveChangesAsync();
+
+ return Ok(game);
}
[HttpPost]
- [Authorize]
- public async Task PostAsync([FromBody] PostGame newGame)
+ //[Authorize]
+ public async Task PostAsync([FromBody] PostConsole newConsole)
{
+ if (!Database.Manufacturers.TryGet(newConsole.ManufacturerId, out var manufacturer)) return NotFound();
try
{
- var game = Database.Games.Add(new Game()
+ var game = Database.Consoles.Add(new Models.Console()
{
- Name = newGame.Name,
- Data = new MetaData()
+ Name = newConsole.Name,
+ Data = new MetaData()
{
- CoverPhoto = newGame.CoverPhoto,
- Description = newGame.Description
- }
+ CoverPhoto = newConsole.CoverPhoto,
+ Description = newConsole.Description
+ },
+ Manufacturer = manufacturer
});
await Database.SaveChangesAsync();
-
- foreach (var release in newGame.Releases)
- {
- if (!Database.Consoles.TryGet(release.ConsoleId, out var console)) continue;
-
- game.Entity.Releases.Add(new Release()
- {
- ReleaseDate = release.Release,
- Console = console
- });
- }
-
- await Database.SaveChangesAsync();
-
- return Ok(game);
+
+ return Ok(game.Entity);
}
catch (Exception ex)
{
diff --git a/DreamsCaster/Controllers/DeveloperController.cs b/DreamsCaster/Controllers/DeveloperController.cs
new file mode 100644
index 0000000..068c521
--- /dev/null
+++ b/DreamsCaster/Controllers/DeveloperController.cs
@@ -0,0 +1,114 @@
+using DreamsCaster.Models;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+using Console = System.Console;
+
+namespace DreamsCaster.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+public class DeveloperController : ControllerBase
+{
+ public AppDbContext Database { get; set; }
+
+ public DeveloperController(AppDbContext dbContext)
+ {
+ Database = dbContext;
+ }
+
+ [HttpGet("{developerId:guid}")]
+ public async Task GetDeveloperAsync([FromRoute] Guid developerId)
+ {
+ try
+ {
+ if (developerId == null)
+ {
+ return Ok();
+ }
+
+ if (!Database.Developers.Include(x=>x.Data).TryGet(developerId, out var val)) return NotFound();
+
+ return Ok(val);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpPost]
+ //[Authorize]
+ public async Task PostDeveloperAsync([FromBody] PostBase publisher)
+ {
+ try
+ {
+ var pub = Database.Developers.Add(new Developer()
+ {
+ Name = publisher.Name,
+ Data = new MetaData()
+ {
+ Description = publisher.Description,
+ CoverPhoto = publisher.CoverPhoto
+ }
+ });
+
+ await Database.SaveChangesAsync();
+
+ return Ok(pub.Entity);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpPut("{developerId:guid}")]
+ //[Authorize]
+ public async Task PatchDeveloperAsync([FromRoute] Guid developerId, [FromBody] PatchInfo patchData)
+ {
+ if (!Database.Developers.TryGet(developerId, out var pub)) return NotFound();
+
+ try
+ {
+ if (patchData.Name.HasValue) pub.Name = patchData.Name;
+ if (patchData.Description.HasValue) pub.Data.Description = patchData.Description;
+ if (patchData.CoverPhoto.HasValue) pub.Data.CoverPhoto = patchData.CoverPhoto;
+
+ await Database.SaveChangesAsync();
+
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpDelete("{developerId:guid}")]
+ //[Authorize]
+ public async Task DeleteDeveloperAsync([FromRoute] Guid developerId)
+ {
+ if (!Database.Developers.TryGet(developerId, out var dev )) return NotFound();
+
+ try
+ {
+ foreach (var game in Database.Games.Where(x=>x.Developers.Contains(dev)))
+ {
+ game.Developers.Remove(dev);
+ }
+
+ Database.Developers.Remove(dev);
+ await Database.SaveChangesAsync();
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+}
\ No newline at end of file
diff --git a/DreamsCaster/Controllers/GameController.cs b/DreamsCaster/Controllers/GameController.cs
index 62f8b37..d8874cd 100644
--- a/DreamsCaster/Controllers/GameController.cs
+++ b/DreamsCaster/Controllers/GameController.cs
@@ -1,5 +1,3 @@
-using System.Runtime.InteropServices.ComTypes;
-using DreamsCaster.Helpers;
using DreamsCaster.Models;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -11,43 +9,26 @@ namespace DreamsCaster.Controllers;
[Route("[controller]")]
public class GameController : ControllerBase
{
- public class PostRelease
- {
- public DateTime Release;
- public Guid ConsoleId;
- }
-
- public class PostGame
- {
- public string Name;
- public string Description;
- public string CoverPhoto;
-
- public List Releases;
- }
+ public AppDbContext Database { get; set; }
- public class PatchGame
+ public GameController(AppDbContext dbContext)
{
- public Optional Name;
- public Optional Description;
- public Optional CoverPhoto;
+ Database = dbContext;
}
-
- public AppDbContext Database { get; set; }
#region Game CRUD
- [HttpGet]
- public IActionResult Get([FromQuery] Guid gameId)
+ [HttpGet("{gameId:guid}")]
+ public IActionResult Get([FromRoute] Guid gameId)
{
if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
return Ok(game);
}
- [HttpGet]
- [Authorize]
- public async Task DeleteAsync([FromQuery] Guid gameId)
+ [HttpDelete("{gameId:guid}")]
+ //[Authorize]
+ public async Task DeleteAsync([FromRoute] Guid gameId)
{
if (!Database.Games.TryGet(gameId, out var game)) return NotFound();
@@ -65,9 +46,9 @@ public class GameController : ControllerBase
return Ok();
}
- [HttpPatch]
- [Authorize]
- public async Task PatchAsync([FromQuery] Guid gameId, [FromBody] PatchGame newData)
+ [HttpPatch("{gameId:guid}")]
+ //[Authorize]
+ public async Task PatchAsync([FromRoute] Guid gameId, [FromBody] PatchInfo newData)
{
if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
@@ -81,7 +62,7 @@ public class GameController : ControllerBase
}
[HttpPost]
- [Authorize]
+ //[Authorize]
public async Task PostAsync([FromBody] PostGame newGame)
{
try
@@ -125,9 +106,9 @@ public class GameController : ControllerBase
#region Releases CUD
- [HttpPatch("{gameId:guid}/releases")]
- [Authorize]
- public async Task PatchReleaseAsync([FromQuery] Guid gameId, [FromBody] PostRelease release)
+ [HttpPost("{gameId:guid}/releases")]
+ //[Authorize]
+ public async Task PostReleaseAsync([FromRoute] Guid gameId, [FromBody] PostRelease release)
{
if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
if (!Database.Consoles.TryGet(release.ConsoleId, out var console)) return NotFound();
@@ -148,8 +129,8 @@ public class GameController : ControllerBase
}
[HttpPut("{gameId:guid}/releases/{releaseId:guid}")]
- [Authorize]
- public async Task PatchReleaseAsync([FromQuery] Guid gameId, [FromQuery] Guid releaseId, [FromBody] DateTime newReleaseDate)
+ //[Authorize]
+ public async Task PatchReleaseAsync([FromRoute] Guid gameId, [FromRoute] Guid releaseId, [FromBody] DateTime newReleaseDate)
{
if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
if (!game.Releases.TryGet(releaseId, out var release)) return NotFound();
@@ -170,8 +151,8 @@ public class GameController : ControllerBase
}
[HttpDelete("{gameId:guid}/releases/{releaseId:guid}")]
- [Authorize]
- public async Task DeleteReleaseAsync([FromQuery] Guid gameId, [FromQuery] Guid releaseId)
+ //[Authorize]
+ public async Task DeleteReleaseAsync([FromRoute] Guid gameId, [FromRoute] Guid releaseId)
{
if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
if (!game.Releases.TryGet(releaseId, out Release release)) return NotFound();
@@ -179,6 +160,7 @@ public class GameController : ControllerBase
try
{
game.Releases.Remove(release);
+ await Database.SaveChangesAsync();
return Ok();
}
catch (Exception ex)
@@ -189,4 +171,103 @@ public class GameController : ControllerBase
}
#endregion Releases CUD
+
+
+ #region Developer AD
+
+
+ [HttpPut("{gameId:guid}/developers/{developerId:guid}")]
+ //[Authorize]
+ public async Task AddDeveloperAsync([FromRoute] Guid gameId, [FromRoute] Guid developerId)
+ {
+ if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
+ if (!Database.Developers.TryGet(developerId, out var dev)) return NotFound();
+
+ try
+ {
+ game.Developers.Add(dev);
+
+ await Database.SaveChangesAsync();
+
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpDelete("{gameId:guid}/developers/{developerId:guid}")]
+ //[Authorize]
+ public async Task RemoveDeveloperAsync([FromRoute] Guid gameId, [FromRoute] Guid developerId)
+ {
+ if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
+ if (!game.Developers.TryGet(developerId, out var dev)) return NotFound();
+
+ try
+ {
+ game.Developers.Remove(dev);
+
+ await Database.SaveChangesAsync();
+
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ #endregion Developer AD
+
+
+ #region Publisher AD
+
+ [HttpPut("{gameId:guid}/publishers/{publisherId:guid}")]
+ //[Authorize]
+ public async Task AddPublisherAsync([FromRoute] Guid gameId, [FromRoute] Guid publisherId)
+ {
+ if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
+ if (!Database.Publishers.TryGet(publisherId, out var pub)) return NotFound();
+
+ try
+ {
+ game.Publishers.Add(pub);
+
+ await Database.SaveChangesAsync();
+
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpDelete("{gameId:guid}/publishers/{publisherId:guid}")]
+ //[Authorize]
+ public async Task RemovePublisherAsync([FromRoute] Guid gameId, [FromRoute] Guid publisherId)
+ {
+ if (!Database.Games.TryGet(gameId, out Game game)) return NotFound();
+ if (!game.Publishers.TryGet(publisherId, out Publisher release)) return NotFound();
+
+ try
+ {
+ game.Publishers.Remove(release);
+
+ await Database.SaveChangesAsync();
+
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ #endregion Publisher AD
}
\ No newline at end of file
diff --git a/DreamsCaster/Controllers/ManufacturerController.cs b/DreamsCaster/Controllers/ManufacturerController.cs
new file mode 100644
index 0000000..e49915e
--- /dev/null
+++ b/DreamsCaster/Controllers/ManufacturerController.cs
@@ -0,0 +1,108 @@
+using DreamsCaster.Models;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Console = System.Console;
+
+namespace DreamsCaster.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+public class ManufacturerController : ControllerBase
+{
+ public AppDbContext Database { get; set; }
+
+ public ManufacturerController(AppDbContext dbContext)
+ {
+ Database = dbContext;
+ }
+
+ [HttpGet("{manufacturerId:guid}")]
+ public async Task GetManufacturerAsync([FromRoute] Guid manufacturerId)
+ {
+ try
+ {
+ if (manufacturerId == null)
+ {
+ return Ok();
+ }
+
+ if (!Database.Manufacturers.TryGet(manufacturerId, out var val)) return NotFound();
+
+ return Ok(val);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpPost]
+ //[Authorize]
+ public async Task PostManufacturerAsync([FromBody] PostBase manufacturer)
+ {
+ try
+ {
+ var pub = Database.Manufacturers.Add(new Manufacturer()
+ {
+ Name = manufacturer.Name,
+ Data = new MetaData()
+ {
+ Description = manufacturer.Description,
+ CoverPhoto = manufacturer.CoverPhoto
+ }
+ });
+
+ await Database.SaveChangesAsync();
+
+ return Ok(pub.Entity);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpPut("{manufacturerId:guid}")]
+ //[Authorize]
+ public async Task PatchManufacturerAsync([FromRoute] Guid manufacturerId, [FromBody] PatchInfo patchData)
+ {
+ if (!Database.Manufacturers.TryGet(manufacturerId, out var manufacturer)) return NotFound();
+
+ try
+ {
+ if (patchData.Name.HasValue) manufacturer.Name = patchData.Name;
+ if (patchData.Description.HasValue) manufacturer.Data.Description = patchData.Description;
+ if (patchData.CoverPhoto.HasValue) manufacturer.Data.CoverPhoto = patchData.CoverPhoto;
+
+ await Database.SaveChangesAsync();
+
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpDelete("{manufacturerId:guid}")]
+ //[Authorize]
+ public async Task DeleteManufacturerAsync([FromRoute] Guid manufacturerId)
+ {
+ if (!Database.Manufacturers.TryGet(manufacturerId, out var manufacturer)) return NotFound();
+
+ try
+ {
+ Database.Manufacturers.Remove(manufacturer);
+ await Database.SaveChangesAsync();
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+}
\ No newline at end of file
diff --git a/DreamsCaster/Controllers/PublisherController.cs b/DreamsCaster/Controllers/PublisherController.cs
new file mode 100644
index 0000000..d14076f
--- /dev/null
+++ b/DreamsCaster/Controllers/PublisherController.cs
@@ -0,0 +1,108 @@
+using DreamsCaster.Models;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Console = System.Console;
+
+namespace DreamsCaster.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+public class PublisherController : ControllerBase
+{
+ public AppDbContext Database { get; set; }
+
+ public PublisherController(AppDbContext dbContext)
+ {
+ Database = dbContext;
+ }
+
+ [HttpGet("{publisherId:guid}")]
+ public async Task GetPublisherAsync([FromRoute] Guid publisherId)
+ {
+ try
+ {
+ if (publisherId == null)
+ {
+ return Ok();
+ }
+
+ if (!Database.Publishers.TryGet(publisherId, out var val)) return NotFound();
+
+ return Ok(val);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpPost]
+ //[Authorize]
+ public async Task PostPublisherAsync([FromBody] PostBase publisher)
+ {
+ try
+ {
+ var pub = Database.Publishers.Add(new Publisher()
+ {
+ Name = publisher.Name,
+ Data = new MetaData()
+ {
+ Description = publisher.Description,
+ CoverPhoto = publisher.CoverPhoto
+ }
+ });
+
+ await Database.SaveChangesAsync();
+
+ return Ok(pub.Entity);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpPut("{publisherId:guid}")]
+ //[Authorize]
+ public async Task PatchPublisherAsync([FromRoute] Guid publisherId, [FromBody] PatchInfo patchData)
+ {
+ if (!Database.Publishers.TryGet(publisherId, out var pub)) return NotFound();
+
+ try
+ {
+ if (patchData.Name.HasValue) pub.Name = patchData.Name;
+ if (patchData.Description.HasValue) pub.Data.Description = patchData.Description;
+ if (patchData.CoverPhoto.HasValue) pub.Data.CoverPhoto = patchData.CoverPhoto;
+
+ await Database.SaveChangesAsync();
+
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+
+ [HttpDelete("{publisherId:guid}")]
+ //[Authorize]
+ public async Task DeletePublisherAsync([FromRoute] Guid publisherId)
+ {
+ if (!Database.Publishers.TryGet(publisherId, out Publisher publisher)) return NotFound();
+
+ try
+ {
+ Database.Publishers.Remove(publisher);
+ await Database.SaveChangesAsync();
+ return Ok();
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return StatusCode(StatusCodes.Status500InternalServerError);
+ }
+ }
+}
\ No newline at end of file
diff --git a/DreamsCaster/DreamsCaster.csproj b/DreamsCaster/DreamsCaster.csproj
index 9d1fd9e..651a8e4 100644
--- a/DreamsCaster/DreamsCaster.csproj
+++ b/DreamsCaster/DreamsCaster.csproj
@@ -9,9 +9,20 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+ Always
+
+
+
diff --git a/DreamsCaster/Helpers/Optional.cs b/DreamsCaster/Helpers/Optional.cs
index e99763d..f1897b5 100644
--- a/DreamsCaster/Helpers/Optional.cs
+++ b/DreamsCaster/Helpers/Optional.cs
@@ -2,13 +2,29 @@ namespace DreamsCaster.Helpers;
public struct Optional
{
- public bool HasValue;
- public T Value;
-
- public Optional(bool hasValue, T value)
+ private T _value = default(T);
+
+ public bool HasValue { get; private set; }
+
+ public T Value
+ {
+ get => _value;
+ set
+ {
+ _value = value;
+ HasValue = true;
+ }
+ }
+
+ public Optional()
+ {
+ HasValue = false;
+ }
+
+ public Optional(bool hasValue, T value) : this()
{
HasValue = hasValue;
- Value = value;
+ _value = value;
}
public static implicit operator T(Optional d) => d.HasValue ? d.Value : default;
diff --git a/DreamsCaster/Migrations/20221103233354_Initial.Designer.cs b/DreamsCaster/Migrations/20221103233354_Initial.Designer.cs
new file mode 100644
index 0000000..56affe5
--- /dev/null
+++ b/DreamsCaster/Migrations/20221103233354_Initial.Designer.cs
@@ -0,0 +1,448 @@
+//
+using System;
+using DreamsCaster;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace DreamsCaster.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ [Migration("20221103233354_Initial")]
+ partial class Initial
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "6.0.10")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("DeveloperGame", b =>
+ {
+ b.Property("DevelopersId")
+ .HasColumnType("char(36)");
+
+ b.Property("GamesId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("DevelopersId", "GamesId");
+
+ b.HasIndex("GamesId");
+
+ b.ToTable("DeveloperGame");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Console", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ManufacturerId")
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ManufacturerId");
+
+ b.ToTable("Consoles");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Developers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Game", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConsoleId")
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ConsoleId");
+
+ b.ToTable("Games");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Manufacturers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("ConsolesMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("DevelopersMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("GamesMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("ManufacturersMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("PublishersMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Publisher", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Publishers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Release", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConsoleId")
+ .HasColumnType("char(36)");
+
+ b.Property("GameId")
+ .HasColumnType("char(36)");
+
+ b.Property("ReleaseDate")
+ .HasColumnType("datetime(6)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ConsoleId");
+
+ b.HasIndex("GameId");
+
+ b.ToTable("Releases");
+ });
+
+ modelBuilder.Entity("GamePublisher", b =>
+ {
+ b.Property("GamesId")
+ .HasColumnType("char(36)");
+
+ b.Property("PublishersId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("GamesId", "PublishersId");
+
+ b.HasIndex("PublishersId");
+
+ b.ToTable("GamePublisher");
+ });
+
+ modelBuilder.Entity("DeveloperGame", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Developer", null)
+ .WithMany()
+ .HasForeignKey("DevelopersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("DreamsCaster.Models.Game", null)
+ .WithMany()
+ .HasForeignKey("GamesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Console", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Manufacturer", "Manufacturer")
+ .WithMany("Consoles")
+ .HasForeignKey("ManufacturerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manufacturer");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Game", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Console", null)
+ .WithMany("Games")
+ .HasForeignKey("ConsoleId");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Console", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Developer", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Game", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Manufacturer", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Publisher", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Release", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Console", "Console")
+ .WithMany()
+ .HasForeignKey("ConsoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("DreamsCaster.Models.Game", "Game")
+ .WithMany("Releases")
+ .HasForeignKey("GameId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Console");
+
+ b.Navigation("Game");
+ });
+
+ modelBuilder.Entity("GamePublisher", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Game", null)
+ .WithMany()
+ .HasForeignKey("GamesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("DreamsCaster.Models.Publisher", null)
+ .WithMany()
+ .HasForeignKey("PublishersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Console", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+
+ b.Navigation("Games");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Game", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+
+ b.Navigation("Releases");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
+ {
+ b.Navigation("Consoles");
+
+ b.Navigation("Data")
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Publisher", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DreamsCaster/Migrations/20221103233354_Initial.cs b/DreamsCaster/Migrations/20221103233354_Initial.cs
new file mode 100644
index 0000000..22d4092
--- /dev/null
+++ b/DreamsCaster/Migrations/20221103233354_Initial.cs
@@ -0,0 +1,393 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace DreamsCaster.Migrations
+{
+ public partial class Initial : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterDatabase()
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Developers",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Name = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Developers", x => x.Id);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Manufacturers",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Name = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Manufacturers", x => x.Id);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Publishers",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Name = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Publishers", x => x.Id);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "DevelopersMetaData",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Description = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ CoverPhoto = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ OwnerId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_DevelopersMetaData", x => x.Id);
+ table.ForeignKey(
+ name: "FK_DevelopersMetaData_Developers_OwnerId",
+ column: x => x.OwnerId,
+ principalTable: "Developers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Consoles",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ ManufacturerId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Name = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Consoles", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Consoles_Manufacturers_ManufacturerId",
+ column: x => x.ManufacturerId,
+ principalTable: "Manufacturers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "ManufacturersMetaData",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Description = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ CoverPhoto = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ OwnerId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ManufacturersMetaData", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ManufacturersMetaData_Manufacturers_OwnerId",
+ column: x => x.OwnerId,
+ principalTable: "Manufacturers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "PublishersMetaData",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Description = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ CoverPhoto = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ OwnerId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_PublishersMetaData", x => x.Id);
+ table.ForeignKey(
+ name: "FK_PublishersMetaData_Publishers_OwnerId",
+ column: x => x.OwnerId,
+ principalTable: "Publishers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "ConsolesMetaData",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Description = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ CoverPhoto = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ OwnerId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ConsolesMetaData", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ConsolesMetaData_Consoles_OwnerId",
+ column: x => x.OwnerId,
+ principalTable: "Consoles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Games",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ ConsoleId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
+ Name = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Games", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Games_Consoles_ConsoleId",
+ column: x => x.ConsoleId,
+ principalTable: "Consoles",
+ principalColumn: "Id");
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "DeveloperGame",
+ columns: table => new
+ {
+ DevelopersId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ GamesId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_DeveloperGame", x => new { x.DevelopersId, x.GamesId });
+ table.ForeignKey(
+ name: "FK_DeveloperGame_Developers_DevelopersId",
+ column: x => x.DevelopersId,
+ principalTable: "Developers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_DeveloperGame_Games_GamesId",
+ column: x => x.GamesId,
+ principalTable: "Games",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "GamePublisher",
+ columns: table => new
+ {
+ GamesId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ PublishersId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_GamePublisher", x => new { x.GamesId, x.PublishersId });
+ table.ForeignKey(
+ name: "FK_GamePublisher_Games_GamesId",
+ column: x => x.GamesId,
+ principalTable: "Games",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_GamePublisher_Publishers_PublishersId",
+ column: x => x.PublishersId,
+ principalTable: "Publishers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "GamesMetaData",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ Description = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ CoverPhoto = table.Column(type: "longtext", nullable: false)
+ .Annotation("MySql:CharSet", "utf8mb4"),
+ OwnerId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_GamesMetaData", x => x.Id);
+ table.ForeignKey(
+ name: "FK_GamesMetaData_Games_OwnerId",
+ column: x => x.OwnerId,
+ principalTable: "Games",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateTable(
+ name: "Releases",
+ columns: table => new
+ {
+ Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ ReleaseDate = table.Column(type: "datetime(6)", nullable: false),
+ GameId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
+ ConsoleId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci")
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Releases", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Releases_Consoles_ConsoleId",
+ column: x => x.ConsoleId,
+ principalTable: "Consoles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Releases_Games_GameId",
+ column: x => x.GameId,
+ principalTable: "Games",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ })
+ .Annotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Consoles_ManufacturerId",
+ table: "Consoles",
+ column: "ManufacturerId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ConsolesMetaData_OwnerId",
+ table: "ConsolesMetaData",
+ column: "OwnerId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_DeveloperGame_GamesId",
+ table: "DeveloperGame",
+ column: "GamesId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_DevelopersMetaData_OwnerId",
+ table: "DevelopersMetaData",
+ column: "OwnerId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GamePublisher_PublishersId",
+ table: "GamePublisher",
+ column: "PublishersId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Games_ConsoleId",
+ table: "Games",
+ column: "ConsoleId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_GamesMetaData_OwnerId",
+ table: "GamesMetaData",
+ column: "OwnerId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ManufacturersMetaData_OwnerId",
+ table: "ManufacturersMetaData",
+ column: "OwnerId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_PublishersMetaData_OwnerId",
+ table: "PublishersMetaData",
+ column: "OwnerId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Releases_ConsoleId",
+ table: "Releases",
+ column: "ConsoleId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Releases_GameId",
+ table: "Releases",
+ column: "GameId");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "ConsolesMetaData");
+
+ migrationBuilder.DropTable(
+ name: "DeveloperGame");
+
+ migrationBuilder.DropTable(
+ name: "DevelopersMetaData");
+
+ migrationBuilder.DropTable(
+ name: "GamePublisher");
+
+ migrationBuilder.DropTable(
+ name: "GamesMetaData");
+
+ migrationBuilder.DropTable(
+ name: "ManufacturersMetaData");
+
+ migrationBuilder.DropTable(
+ name: "PublishersMetaData");
+
+ migrationBuilder.DropTable(
+ name: "Releases");
+
+ migrationBuilder.DropTable(
+ name: "Developers");
+
+ migrationBuilder.DropTable(
+ name: "Publishers");
+
+ migrationBuilder.DropTable(
+ name: "Games");
+
+ migrationBuilder.DropTable(
+ name: "Consoles");
+
+ migrationBuilder.DropTable(
+ name: "Manufacturers");
+ }
+ }
+}
diff --git a/DreamsCaster/Migrations/20221103235329_NullableMetaData.Designer.cs b/DreamsCaster/Migrations/20221103235329_NullableMetaData.Designer.cs
new file mode 100644
index 0000000..5b981db
--- /dev/null
+++ b/DreamsCaster/Migrations/20221103235329_NullableMetaData.Designer.cs
@@ -0,0 +1,438 @@
+//
+using System;
+using DreamsCaster;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace DreamsCaster.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ [Migration("20221103235329_NullableMetaData")]
+ partial class NullableMetaData
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "6.0.10")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("DeveloperGame", b =>
+ {
+ b.Property("DevelopersId")
+ .HasColumnType("char(36)");
+
+ b.Property("GamesId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("DevelopersId", "GamesId");
+
+ b.HasIndex("GamesId");
+
+ b.ToTable("DeveloperGame");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Console", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ManufacturerId")
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ManufacturerId");
+
+ b.ToTable("Consoles");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Developers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Game", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConsoleId")
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ConsoleId");
+
+ b.ToTable("Games");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Manufacturers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("ConsolesMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("DevelopersMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("GamesMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("ManufacturersMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .HasColumnType("longtext");
+
+ b.Property("Description")
+ .HasColumnType("longtext");
+
+ b.Property("OwnerId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId")
+ .IsUnique();
+
+ b.ToTable("PublishersMetaData");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Publisher", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Publishers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Release", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConsoleId")
+ .HasColumnType("char(36)");
+
+ b.Property("GameId")
+ .HasColumnType("char(36)");
+
+ b.Property("ReleaseDate")
+ .HasColumnType("datetime(6)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ConsoleId");
+
+ b.HasIndex("GameId");
+
+ b.ToTable("Releases");
+ });
+
+ modelBuilder.Entity("GamePublisher", b =>
+ {
+ b.Property("GamesId")
+ .HasColumnType("char(36)");
+
+ b.Property("PublishersId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("GamesId", "PublishersId");
+
+ b.HasIndex("PublishersId");
+
+ b.ToTable("GamePublisher");
+ });
+
+ modelBuilder.Entity("DeveloperGame", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Developer", null)
+ .WithMany()
+ .HasForeignKey("DevelopersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("DreamsCaster.Models.Game", null)
+ .WithMany()
+ .HasForeignKey("GamesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Console", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Manufacturer", "Manufacturer")
+ .WithMany("Consoles")
+ .HasForeignKey("ManufacturerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manufacturer");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Game", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Console", null)
+ .WithMany("Games")
+ .HasForeignKey("ConsoleId");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Console", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Developer", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Game", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Manufacturer", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Publisher", "Owner")
+ .WithOne("Data")
+ .HasForeignKey("DreamsCaster.Models.MetaData", "OwnerId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Release", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Console", "Console")
+ .WithMany()
+ .HasForeignKey("ConsoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("DreamsCaster.Models.Game", "Game")
+ .WithMany("Releases")
+ .HasForeignKey("GameId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Console");
+
+ b.Navigation("Game");
+ });
+
+ modelBuilder.Entity("GamePublisher", b =>
+ {
+ b.HasOne("DreamsCaster.Models.Game", null)
+ .WithMany()
+ .HasForeignKey("GamesId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("DreamsCaster.Models.Publisher", null)
+ .WithMany()
+ .HasForeignKey("PublishersId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Console", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+
+ b.Navigation("Games");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Game", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+
+ b.Navigation("Releases");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
+ {
+ b.Navigation("Consoles");
+
+ b.Navigation("Data")
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Publisher", b =>
+ {
+ b.Navigation("Data")
+ .IsRequired();
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DreamsCaster/Migrations/20221103235329_NullableMetaData.cs b/DreamsCaster/Migrations/20221103235329_NullableMetaData.cs
new file mode 100644
index 0000000..14da6af
--- /dev/null
+++ b/DreamsCaster/Migrations/20221103235329_NullableMetaData.cs
@@ -0,0 +1,295 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace DreamsCaster.Migrations
+{
+ public partial class NullableMetaData : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "PublishersMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "PublishersMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "ManufacturersMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "ManufacturersMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "GamesMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "GamesMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "DevelopersMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "DevelopersMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "ConsolesMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "ConsolesMetaData",
+ type: "longtext",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "longtext")
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.UpdateData(
+ table: "PublishersMetaData",
+ keyColumn: "Description",
+ keyValue: null,
+ column: "Description",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "PublishersMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "PublishersMetaData",
+ keyColumn: "CoverPhoto",
+ keyValue: null,
+ column: "CoverPhoto",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "PublishersMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "ManufacturersMetaData",
+ keyColumn: "Description",
+ keyValue: null,
+ column: "Description",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "ManufacturersMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "ManufacturersMetaData",
+ keyColumn: "CoverPhoto",
+ keyValue: null,
+ column: "CoverPhoto",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "ManufacturersMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "GamesMetaData",
+ keyColumn: "Description",
+ keyValue: null,
+ column: "Description",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "GamesMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "GamesMetaData",
+ keyColumn: "CoverPhoto",
+ keyValue: null,
+ column: "CoverPhoto",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "GamesMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "DevelopersMetaData",
+ keyColumn: "Description",
+ keyValue: null,
+ column: "Description",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "DevelopersMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "DevelopersMetaData",
+ keyColumn: "CoverPhoto",
+ keyValue: null,
+ column: "CoverPhoto",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "DevelopersMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "ConsolesMetaData",
+ keyColumn: "Description",
+ keyValue: null,
+ column: "Description",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "Description",
+ table: "ConsolesMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+
+ migrationBuilder.UpdateData(
+ table: "ConsolesMetaData",
+ keyColumn: "CoverPhoto",
+ keyValue: null,
+ column: "CoverPhoto",
+ value: "");
+
+ migrationBuilder.AlterColumn(
+ name: "CoverPhoto",
+ table: "ConsolesMetaData",
+ type: "longtext",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "longtext",
+ oldNullable: true)
+ .Annotation("MySql:CharSet", "utf8mb4")
+ .OldAnnotation("MySql:CharSet", "utf8mb4");
+ }
+ }
+}
diff --git a/DreamsCaster/Migrations/AppDbContextModelSnapshot.cs b/DreamsCaster/Migrations/AppDbContextModelSnapshot.cs
new file mode 100644
index 0000000..d5a939f
--- /dev/null
+++ b/DreamsCaster/Migrations/AppDbContextModelSnapshot.cs
@@ -0,0 +1,436 @@
+//
+using System;
+using DreamsCaster;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace DreamsCaster.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ partial class AppDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "6.0.10")
+ .HasAnnotation("Relational:MaxIdentifierLength", 64);
+
+ modelBuilder.Entity("DeveloperGame", b =>
+ {
+ b.Property("DevelopersId")
+ .HasColumnType("char(36)");
+
+ b.Property("GamesId")
+ .HasColumnType("char(36)");
+
+ b.HasKey("DevelopersId", "GamesId");
+
+ b.HasIndex("GamesId");
+
+ b.ToTable("DeveloperGame");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Console", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ManufacturerId")
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ManufacturerId");
+
+ b.ToTable("Consoles");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Developers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Game", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("ConsoleId")
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ConsoleId");
+
+ b.ToTable("Games");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("longtext");
+
+ b.HasKey("Id");
+
+ b.ToTable("Manufacturers");
+ });
+
+ modelBuilder.Entity("DreamsCaster.Models.MetaData", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("char(36)");
+
+ b.Property("CoverPhoto")
+ .HasColumnType("longtext");
+
+ b.Property