Initial impl of backend
This commit is contained in:
11
.idea/.idea.DreamsCaster/.idea/efCoreCommonOptions.xml
generated
Normal file
11
.idea/.idea.DreamsCaster/.idea/efCoreCommonOptions.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EfCoreCommonOptions">
|
||||
<option name="solutionLevelOptions">
|
||||
<map>
|
||||
<entry key="migrationsProject" value="7ef668eb-6d79-4a51-a161-f4e99dccd789" />
|
||||
<entry key="startupProject" value="7ef668eb-6d79-4a51-a161-f4e99dccd789" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -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<Game> Games;
|
||||
public DbSet<Console> Consoles;
|
||||
public DbSet<Game> Games { get; set; }
|
||||
public DbSet<Console> Consoles { get; set; }
|
||||
|
||||
public DbSet<Developer> Developers { get; set; }
|
||||
public DbSet<Publisher> Publishers { get; set; }
|
||||
public DbSet<Manufacturer> Manufacturers { get; set; }
|
||||
public DbSet<Release> Releases { get; set; }
|
||||
|
||||
public DbSet<MetaData<Game>> GamesMetaData { get; set; }
|
||||
public DbSet<MetaData<Console>> ConsolesMetaData { get; set; }
|
||||
public DbSet<MetaData<Developer>> DevelopersMetaData { get; set; }
|
||||
public DbSet<MetaData<Publisher>> PublishersMetaData { get; set; }
|
||||
public DbSet<MetaData<Manufacturer>> ManufacturersMetaData { get; set; }
|
||||
|
||||
public AppDbContext() : base() { }
|
||||
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
ConfigureMetaDataFor<Console>(modelBuilder);
|
||||
ConfigureMetaDataFor<Game>(modelBuilder);
|
||||
ConfigureMetaDataFor<Publisher>(modelBuilder);
|
||||
ConfigureMetaDataFor<Developer>(modelBuilder);
|
||||
ConfigureMetaDataFor<Manufacturer>(modelBuilder);
|
||||
}
|
||||
|
||||
void ConfigureMetaDataFor<T>(ModelBuilder modelBuilder) where T : MetaDataContainer<T>
|
||||
{
|
||||
modelBuilder.Entity<T>()
|
||||
.HasOne(a => a.Data)
|
||||
.WithOne(b => b.Owner)
|
||||
.HasForeignKey<MetaData<T>>(c => c.OwnerId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
}
|
||||
}
|
||||
|
||||
public static class DatabaseExtensions
|
||||
|
||||
34
DreamsCaster/AppDbContextFactory.cs
Normal file
34
DreamsCaster/AppDbContextFactory.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
|
||||
namespace DreamsCaster;
|
||||
|
||||
public class AppDbContextFactory : IDesignTimeDbContextFactory<AppDbContext> {
|
||||
public AppDbContext CreateDbContext (ILoggerFactory? loggerFactory, IConfiguration config) {
|
||||
var connStr = config.GetConnectionString ("Database");
|
||||
|
||||
var serverVersion = ServerVersion.AutoDetect (connStr);
|
||||
|
||||
var optionsBuilder = new DbContextOptionsBuilder<AppDbContext> ()
|
||||
#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);
|
||||
}
|
||||
}
|
||||
@@ -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<IActionResult> DeleteAsync([FromQuery] Guid consoleId)
|
||||
[HttpDelete("{consoleId:guid}")]
|
||||
//[Authorize]
|
||||
public async Task<IActionResult> DeleteAsync([FromRoute] Guid consoleId)
|
||||
{
|
||||
if (!Database.Games.TryGet(consoleId, out var game)) return NotFound();
|
||||
|
||||
@@ -40,46 +44,43 @@ public class ConsoleController : ControllerBase
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPatch]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> PatchAsync([FromQuery] Guid consoleId)
|
||||
[HttpPatch("{consoleId:guid}")]
|
||||
//[Authorize]
|
||||
public async Task<IActionResult> PatchAsync([FromRoute] Guid consoleId, [FromBody] PatchInfo newData)
|
||||
{
|
||||
if (!Database.Games.TryGet(consoleId, out Game game)) return NotFound();
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> PostAsync([FromBody] PostGame newGame)
|
||||
{
|
||||
try
|
||||
{
|
||||
var game = Database.Games.Add(new Game()
|
||||
{
|
||||
Name = newGame.Name,
|
||||
Data = new MetaData<Game>()
|
||||
{
|
||||
CoverPhoto = newGame.CoverPhoto,
|
||||
Description = newGame.Description
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
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<IActionResult> PostAsync([FromBody] PostConsole newConsole)
|
||||
{
|
||||
if (!Database.Manufacturers.TryGet(newConsole.ManufacturerId, out var manufacturer)) return NotFound();
|
||||
try
|
||||
{
|
||||
var game = Database.Consoles.Add(new Models.Console()
|
||||
{
|
||||
Name = newConsole.Name,
|
||||
Data = new MetaData<Models.Console>()
|
||||
{
|
||||
CoverPhoto = newConsole.CoverPhoto,
|
||||
Description = newConsole.Description
|
||||
},
|
||||
Manufacturer = manufacturer
|
||||
});
|
||||
|
||||
await Database.SaveChangesAsync();
|
||||
|
||||
return Ok(game.Entity);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
|
||||
114
DreamsCaster/Controllers/DeveloperController.cs
Normal file
114
DreamsCaster/Controllers/DeveloperController.cs
Normal file
@@ -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<IActionResult> 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<IActionResult> PostDeveloperAsync([FromBody] PostBase publisher)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pub = Database.Developers.Add(new Developer()
|
||||
{
|
||||
Name = publisher.Name,
|
||||
Data = new MetaData<Developer>()
|
||||
{
|
||||
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<IActionResult> 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<IActionResult> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<PostRelease> Releases;
|
||||
}
|
||||
|
||||
public class PatchGame
|
||||
{
|
||||
public Optional<string> Name;
|
||||
public Optional<string> Description;
|
||||
public Optional<string> CoverPhoto;
|
||||
}
|
||||
|
||||
public AppDbContext Database { get; set; }
|
||||
|
||||
public GameController(AppDbContext dbContext)
|
||||
{
|
||||
Database = dbContext;
|
||||
}
|
||||
|
||||
#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<IActionResult> DeleteAsync([FromQuery] Guid gameId)
|
||||
[HttpDelete("{gameId:guid}")]
|
||||
//[Authorize]
|
||||
public async Task<IActionResult> 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<IActionResult> PatchAsync([FromQuery] Guid gameId, [FromBody] PatchGame newData)
|
||||
[HttpPatch("{gameId:guid}")]
|
||||
//[Authorize]
|
||||
public async Task<IActionResult> 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<IActionResult> PostAsync([FromBody] PostGame newGame)
|
||||
{
|
||||
try
|
||||
@@ -125,9 +106,9 @@ public class GameController : ControllerBase
|
||||
|
||||
#region Releases CUD
|
||||
|
||||
[HttpPatch("{gameId:guid}/releases")]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> PatchReleaseAsync([FromQuery] Guid gameId, [FromBody] PostRelease release)
|
||||
[HttpPost("{gameId:guid}/releases")]
|
||||
//[Authorize]
|
||||
public async Task<IActionResult> 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<IActionResult> PatchReleaseAsync([FromQuery] Guid gameId, [FromQuery] Guid releaseId, [FromBody] DateTime newReleaseDate)
|
||||
//[Authorize]
|
||||
public async Task<IActionResult> 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<IActionResult> DeleteReleaseAsync([FromQuery] Guid gameId, [FromQuery] Guid releaseId)
|
||||
//[Authorize]
|
||||
public async Task<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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<IActionResult> 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
|
||||
}
|
||||
108
DreamsCaster/Controllers/ManufacturerController.cs
Normal file
108
DreamsCaster/Controllers/ManufacturerController.cs
Normal file
@@ -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<IActionResult> 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<IActionResult> PostManufacturerAsync([FromBody] PostBase manufacturer)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pub = Database.Manufacturers.Add(new Manufacturer()
|
||||
{
|
||||
Name = manufacturer.Name,
|
||||
Data = new MetaData<Manufacturer>()
|
||||
{
|
||||
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<IActionResult> 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<IActionResult> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
108
DreamsCaster/Controllers/PublisherController.cs
Normal file
108
DreamsCaster/Controllers/PublisherController.cs
Normal file
@@ -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<IActionResult> 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<IActionResult> PostPublisherAsync([FromBody] PostBase publisher)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pub = Database.Publishers.Add(new Publisher()
|
||||
{
|
||||
Name = publisher.Name,
|
||||
Data = new MetaData<Publisher>()
|
||||
{
|
||||
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<IActionResult> 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<IActionResult> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,20 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="6.0.10" />
|
||||
<PackageReference Include="PagedList.EntityFramework" Version="1.0.1" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json.default">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -2,13 +2,29 @@ namespace DreamsCaster.Helpers;
|
||||
|
||||
public struct Optional<T>
|
||||
{
|
||||
public bool HasValue;
|
||||
public T Value;
|
||||
private T _value = default(T);
|
||||
|
||||
public Optional(bool hasValue, T value)
|
||||
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<T> d) => d.HasValue ? d.Value : default;
|
||||
|
||||
448
DreamsCaster/Migrations/20221103233354_Initial.Designer.cs
generated
Normal file
448
DreamsCaster/Migrations/20221103233354_Initial.Designer.cs
generated
Normal file
@@ -0,0 +1,448 @@
|
||||
// <auto-generated />
|
||||
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<Guid>("DevelopersId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GamesId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("DevelopersId", "GamesId");
|
||||
|
||||
b.HasIndex("GamesId");
|
||||
|
||||
b.ToTable("DeveloperGame");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Console", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ManufacturerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufacturerId");
|
||||
|
||||
b.ToTable("Consoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Developers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Game", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("ConsoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConsoleId");
|
||||
|
||||
b.ToTable("Games");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufacturers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Console>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ConsolesMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("DevelopersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("GamesMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ManufacturersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PublishersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Publisher", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Publishers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Release", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ConsoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GameId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("ReleaseDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConsoleId");
|
||||
|
||||
b.HasIndex("GameId");
|
||||
|
||||
b.ToTable("Releases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GamePublisher", b =>
|
||||
{
|
||||
b.Property<Guid>("GamesId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("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<DreamsCaster.Models.Console>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Console", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Console>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Developer", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Game", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Manufacturer", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Publisher", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", "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
|
||||
}
|
||||
}
|
||||
}
|
||||
393
DreamsCaster/Migrations/20221103233354_Initial.cs
Normal file
393
DreamsCaster/Migrations/20221103233354_Initial.cs
Normal file
@@ -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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CoverPhoto = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
OwnerId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ManufacturerId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CoverPhoto = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
OwnerId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CoverPhoto = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
OwnerId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CoverPhoto = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
OwnerId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ConsoleId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
GamesId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
PublishersId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CoverPhoto = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
OwnerId = table.Column<Guid>(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<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ReleaseDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
GameId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ConsoleId = table.Column<Guid>(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");
|
||||
}
|
||||
}
|
||||
}
|
||||
438
DreamsCaster/Migrations/20221103235329_NullableMetaData.Designer.cs
generated
Normal file
438
DreamsCaster/Migrations/20221103235329_NullableMetaData.Designer.cs
generated
Normal file
@@ -0,0 +1,438 @@
|
||||
// <auto-generated />
|
||||
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<Guid>("DevelopersId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GamesId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("DevelopersId", "GamesId");
|
||||
|
||||
b.HasIndex("GamesId");
|
||||
|
||||
b.ToTable("DeveloperGame");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Console", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ManufacturerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufacturerId");
|
||||
|
||||
b.ToTable("Consoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Developers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Game", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("ConsoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConsoleId");
|
||||
|
||||
b.ToTable("Games");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufacturers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Console>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ConsolesMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("DevelopersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("GamesMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ManufacturersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PublishersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Publisher", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Publishers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Release", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ConsoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GameId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("ReleaseDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConsoleId");
|
||||
|
||||
b.HasIndex("GameId");
|
||||
|
||||
b.ToTable("Releases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GamePublisher", b =>
|
||||
{
|
||||
b.Property<Guid>("GamesId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("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<DreamsCaster.Models.Console>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Console", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Console>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Developer", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Game", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Manufacturer", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Publisher", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", "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
|
||||
}
|
||||
}
|
||||
}
|
||||
295
DreamsCaster/Migrations/20221103235329_NullableMetaData.cs
Normal file
295
DreamsCaster/Migrations/20221103235329_NullableMetaData.cs
Normal file
@@ -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<string>(
|
||||
name: "Description",
|
||||
table: "PublishersMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "CoverPhoto",
|
||||
table: "PublishersMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Description",
|
||||
table: "ManufacturersMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "CoverPhoto",
|
||||
table: "ManufacturersMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Description",
|
||||
table: "GamesMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "CoverPhoto",
|
||||
table: "GamesMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Description",
|
||||
table: "DevelopersMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "CoverPhoto",
|
||||
table: "DevelopersMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "Description",
|
||||
table: "ConsolesMetaData",
|
||||
type: "longtext",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext")
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
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<string>(
|
||||
name: "CoverPhoto",
|
||||
table: "ConsolesMetaData",
|
||||
type: "longtext",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "longtext",
|
||||
oldNullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
}
|
||||
}
|
||||
436
DreamsCaster/Migrations/AppDbContextModelSnapshot.cs
Normal file
436
DreamsCaster/Migrations/AppDbContextModelSnapshot.cs
Normal file
@@ -0,0 +1,436 @@
|
||||
// <auto-generated />
|
||||
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<Guid>("DevelopersId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GamesId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("DevelopersId", "GamesId");
|
||||
|
||||
b.HasIndex("GamesId");
|
||||
|
||||
b.ToTable("DeveloperGame");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Console", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ManufacturerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufacturerId");
|
||||
|
||||
b.ToTable("Consoles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Developer", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Developers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Game", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid?>("ConsoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConsoleId");
|
||||
|
||||
b.ToTable("Games");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Manufacturer", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufacturers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Console>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ConsolesMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("DevelopersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("GamesMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("ManufacturersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CoverPhoto")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("OwnerId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OwnerId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("PublishersMetaData");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Publisher", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Publishers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.Release", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ConsoleId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("GameId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("ReleaseDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ConsoleId");
|
||||
|
||||
b.HasIndex("GameId");
|
||||
|
||||
b.ToTable("Releases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GamePublisher", b =>
|
||||
{
|
||||
b.Property<Guid>("GamesId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("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<DreamsCaster.Models.Console>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Console", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Console>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Developer", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Developer>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Game", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Game>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Manufacturer", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Manufacturer>", "OwnerId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Owner");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", b =>
|
||||
{
|
||||
b.HasOne("DreamsCaster.Models.Publisher", "Owner")
|
||||
.WithOne("Data")
|
||||
.HasForeignKey("DreamsCaster.Models.MetaData<DreamsCaster.Models.Publisher>", "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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,67 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using DreamsCaster.Helpers;
|
||||
|
||||
namespace DreamsCaster.Models;
|
||||
|
||||
public class IdEntity
|
||||
{
|
||||
public Guid Id;
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
}
|
||||
|
||||
public class MetaData<T> : IdEntity
|
||||
{
|
||||
public string Description;
|
||||
public string CoverPhoto;
|
||||
public string? Description { get; set; }
|
||||
public string? CoverPhoto { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual Guid OwnerId { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual T Owner { get; set; }
|
||||
}
|
||||
|
||||
public class MetaDataContainer<T> : IdEntity
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public virtual MetaData<T> Data { get; set; }
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public class PatchInfo
|
||||
{
|
||||
public Optional<string> Name { get; set; } = new();
|
||||
public Optional<string> Description { get; set; } = new();
|
||||
public Optional<string> CoverPhoto { get; set; } = new();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PostBase
|
||||
{
|
||||
[Required] public string Name { get; set; }
|
||||
public string? Description { get; set; } = null;
|
||||
public string? CoverPhoto { get; set; } = null;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PostRelease : PostBase
|
||||
{
|
||||
public DateTime Release { get; set; }
|
||||
public Guid ConsoleId { get; set; }
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PostGame : PostBase
|
||||
{
|
||||
public List<PostRelease> Releases { get; set; }
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PostConsole : PostBase
|
||||
{
|
||||
public Guid ManufacturerId { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DreamsCaster.Models;
|
||||
|
||||
public class Console : IdEntity
|
||||
public class Console : MetaDataContainer<Console>
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public virtual ICollection<Game> Games { get; set; }
|
||||
|
||||
public virtual MetaData<Console> Data { get; set; }
|
||||
public virtual Manufacturer Manufacturer { get; set; }
|
||||
}
|
||||
6
DreamsCaster/Models/Developer.cs
Normal file
6
DreamsCaster/Models/Developer.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace DreamsCaster.Models;
|
||||
|
||||
public class Developer : MetaDataContainer<Developer>
|
||||
{
|
||||
public virtual ICollection<Game> Games { get; set; }
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
namespace DreamsCaster.Models;
|
||||
|
||||
public class Game : IdEntity
|
||||
public class Game : MetaDataContainer<Game>
|
||||
{
|
||||
public string Name;
|
||||
public virtual ICollection<Release> Releases { get; set; }
|
||||
|
||||
public ICollection<Release> Releases;
|
||||
public virtual ICollection<Developer> Developers { get; set; }
|
||||
public virtual ICollection<Publisher> Publishers { get; set; }
|
||||
|
||||
public virtual MetaData<Game> Data { get; set; }
|
||||
}
|
||||
6
DreamsCaster/Models/Manufacturer.cs
Normal file
6
DreamsCaster/Models/Manufacturer.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace DreamsCaster.Models;
|
||||
|
||||
public class Manufacturer : MetaDataContainer<Manufacturer>
|
||||
{
|
||||
public virtual ICollection<Console> Consoles { get; set; }
|
||||
}
|
||||
6
DreamsCaster/Models/Publisher.cs
Normal file
6
DreamsCaster/Models/Publisher.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace DreamsCaster.Models;
|
||||
|
||||
public class Publisher : MetaDataContainer<Publisher>
|
||||
{
|
||||
public virtual ICollection<Game> Games { get; set; }
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace DreamsCaster.Models;
|
||||
|
||||
public class Release : IdEntity
|
||||
{
|
||||
public DateTime ReleaseDate;
|
||||
public DateTime ReleaseDate { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual Game Game { get; set; }
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
using DreamsCaster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
@@ -7,6 +10,15 @@ builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddDbContext<AppDbContext>(options =>
|
||||
{
|
||||
var connStr = builder.Configuration.GetConnectionString("Database");
|
||||
|
||||
var serverVersion = ServerVersion.AutoDetect(connStr);
|
||||
|
||||
options.UseLazyLoadingProxies().UseMySql(connStr, serverVersion, x => x.EnableRetryOnFailure());
|
||||
}, ServiceLifetime.Transient);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
108
DreamsCaster/appsettings.json.default
Normal file
108
DreamsCaster/appsettings.json.default
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"NLog": {
|
||||
"extensions": [
|
||||
{ "assembly": "Sentry.NLog" }
|
||||
],
|
||||
"targets": {
|
||||
"sentry": {
|
||||
"type": "Sentry",
|
||||
"layout": "${message}",
|
||||
"environment": "Development",
|
||||
"breadcrumbLayout": "${message}",
|
||||
"minimumBreadcrumbLevel": "Debug",
|
||||
"minimumEventLevel": "Error",
|
||||
"options": {
|
||||
"sendDefaultPii": true,
|
||||
"attachStacktrace": true,
|
||||
"shutdownTimeoutSeconds": 5,
|
||||
"debug": false,
|
||||
"includeEventDataOnBreadcrumbs": true
|
||||
}
|
||||
},
|
||||
"coloredConsole": {
|
||||
"type": "ColoredConsole",
|
||||
"layout": "${longdate}|${pad:padding=5:inner=${level:uppercase=true}}|${callsite}|${message}",
|
||||
"rowHighlightingRules": [
|
||||
{
|
||||
"condition": "level == LogLevel.Debug",
|
||||
"foregroundColor": "White"
|
||||
},
|
||||
{
|
||||
"condition": "level == LogLevel.Info",
|
||||
"foregroundColor": "Blue"
|
||||
},
|
||||
{
|
||||
"condition": "level == LogLevel.Warn",
|
||||
"foregroundColor": "Yellow"
|
||||
},
|
||||
{
|
||||
"condition": "level == LogLevel.Error",
|
||||
"foregroundColor": "Red"
|
||||
},
|
||||
{
|
||||
"condition": "level == LogLevel.Fatal",
|
||||
"foregroundColor": "Red",
|
||||
"backgroundColor": "White"
|
||||
}
|
||||
]
|
||||
},
|
||||
"infoFile": {
|
||||
"type": "File",
|
||||
"layout": "${longdate} ${pad:padding=5:inner=${level:uppercase=true}} ${logger} ${message}",
|
||||
"fileName": "${basedir}/logs/info.log",
|
||||
"keepFileOpen": false,
|
||||
"encoding": "iso-8859-2"
|
||||
},
|
||||
"errorFile": {
|
||||
"type": "File",
|
||||
"layout": "${longdate} ${pad:padding=5:inner=${level:uppercase=true}} ${logger} ${message}${newline}${exception:format=ToString,StackTrace}",
|
||||
"fileName": "${basedir}/logs/error.log",
|
||||
"keepFileOpen": false,
|
||||
"encoding": "iso-8859-2"
|
||||
},
|
||||
"allFile": {
|
||||
"type": "File",
|
||||
"layout": "${longdate} ${pad:padding=5:inner=${level:uppercase=true}} ${logger} ${message}${newline}${exception:format=ToString,StackTrace}",
|
||||
"fileName": "${basedir}/logs/all.log",
|
||||
"keepFileOpen": false,
|
||||
"encoding": "iso-8859-2"
|
||||
}
|
||||
},
|
||||
"rules": [
|
||||
{
|
||||
"logger": "Microsoft.*",
|
||||
"maxLevel": "Error",
|
||||
"final": true
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Trace",
|
||||
"writeTo": "allFile,coloredConsole"
|
||||
},
|
||||
{
|
||||
"logger": "*",
|
||||
"minLevel": "Warn",
|
||||
"maxLevel": "Fatal",
|
||||
"writeTo": "errorFile,sentry"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Sentry": {
|
||||
"Dsn": "",
|
||||
"MaxRequestBodySize": "Always",
|
||||
"MinimumBreadcrumbLevel": "Debug",
|
||||
"MinimumEventLevel": "Warning",
|
||||
"AttachStackTrace": true,
|
||||
"DiagnosticsLevel": "Error",
|
||||
"TracesSampleRate": 1.0
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Database": ""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user