From 15551ed8f8b0bee487e22b74dd88cf5959fe4fe3 Mon Sep 17 00:00:00 2001 From: jvyden Date: Mon, 18 Oct 2021 17:27:22 -0400 Subject: [PATCH] Add database support for hearted levels --- DatabaseMigrations/8.sql | 16 ++++++++++++++++ ...QueueController.cs => LevelListController.cs} | 8 +++++++- ProjectLighthouse/Database.cs | 1 + ProjectLighthouse/Types/HeartedLevel.cs | 16 ++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 DatabaseMigrations/8.sql rename ProjectLighthouse/Controllers/{LevelQueueController.cs => LevelListController.cs} (92%) create mode 100644 ProjectLighthouse/Types/HeartedLevel.cs diff --git a/DatabaseMigrations/8.sql b/DatabaseMigrations/8.sql new file mode 100644 index 00000000..8f93e6f7 --- /dev/null +++ b/DatabaseMigrations/8.sql @@ -0,0 +1,16 @@ +create table HeartedLevels +( + HeartedLevelId int, + UserId int not null, + SlotId int not null +); + +create unique index HeartedLevels_HeartedLevelId_uindex + on HeartedLevels (HeartedLevelId); + +alter table HeartedLevels + add constraint HeartedLevels_pk + primary key (HeartedLevelId); + +alter table HeartedLevels + modify HeartedLevelId int auto_increment; diff --git a/ProjectLighthouse/Controllers/LevelQueueController.cs b/ProjectLighthouse/Controllers/LevelListController.cs similarity index 92% rename from ProjectLighthouse/Controllers/LevelQueueController.cs rename to ProjectLighthouse/Controllers/LevelListController.cs index 85d464c8..59f21cc8 100644 --- a/ProjectLighthouse/Controllers/LevelQueueController.cs +++ b/ProjectLighthouse/Controllers/LevelListController.cs @@ -11,7 +11,8 @@ namespace ProjectLighthouse.Controllers { [ApiController] [Route("LITTLEBIGPLANETPS3_XML/")] [Produces("text/xml")] - public class LevelQueueController : ControllerBase { + public class LevelListController : ControllerBase { + #region Level Queue (lolcatftw) [HttpGet("slots/lolcatftw/{username}")] public IActionResult GetLevelQueue(string username) { IEnumerable queuedLevels = new Database().QueuedLevels @@ -59,5 +60,10 @@ namespace ProjectLighthouse.Controllers { return this.Ok(); } + #endregion + + #region Hearted Levels + + #endregion } } \ No newline at end of file diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index 295ddcd5..2182c8ec 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -10,6 +10,7 @@ namespace ProjectLighthouse { public DbSet Locations { get; set; } public DbSet Slots { get; set; } public DbSet QueuedLevels { get; set; } + public DbSet HeartedLevels { get; set; } public DbSet Comments { get; set; } public DbSet Tokens { get; set; } diff --git a/ProjectLighthouse/Types/HeartedLevel.cs b/ProjectLighthouse/Types/HeartedLevel.cs new file mode 100644 index 00000000..09b99c0b --- /dev/null +++ b/ProjectLighthouse/Types/HeartedLevel.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace ProjectLighthouse.Types { + public class HeartedLevel { + [Key] public int HeartedLevelId { get; set; } + + public int UserId { get; set; } + + [ForeignKey(nameof(UserId))] public User User { get; set; } + + public int SlotId { get; set; } + + [ForeignKey(nameof(SlotId))] public Slot Slot { get; set; } + } +} \ No newline at end of file