diff --git a/ProjectLighthouse/Controllers/Website/SlotPageController.cs b/ProjectLighthouse/Controllers/Website/SlotPageController.cs index 705e3291..ee93b470 100644 --- a/ProjectLighthouse/Controllers/Website/SlotPageController.cs +++ b/ProjectLighthouse/Controllers/Website/SlotPageController.cs @@ -5,6 +5,11 @@ using LBPUnion.ProjectLighthouse.Types.Levels; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +// I would like to apologize in advance for anyone dealing with this file. +// Theres probably a better way to do this with delegates but I'm tired. +// TODO: Clean up this file +// - jvyden + namespace LBPUnion.ProjectLighthouse.Controllers.Website { [ApiController] @@ -19,8 +24,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website } [HttpGet("heart")] - public async Task HeartLevel([FromRoute] int id) + public async Task HeartLevel([FromRoute] int id, [FromQuery] string? callbackUrl) { + if (string.IsNullOrEmpty(callbackUrl)) + { + callbackUrl = "~/slot/" + id; + } + User? user = this.database.UserFromWebRequest(this.Request); if (user == null) return this.Redirect("~/login"); @@ -29,12 +39,17 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website await this.database.HeartLevel(user, heartedSlot); - return this.Redirect("~/slot/" + id); + return this.Redirect(callbackUrl); } [HttpGet("unheart")] - public async Task UnheartLevel([FromRoute] int id) + public async Task UnheartLevel([FromRoute] int id, [FromQuery] string? callbackUrl) { + if (string.IsNullOrEmpty(callbackUrl)) + { + callbackUrl = "~/slot/" + id; + } + User? user = this.database.UserFromWebRequest(this.Request); if (user == null) return this.Redirect("~/login"); @@ -43,12 +58,17 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website await this.database.UnheartLevel(user, heartedSlot); - return this.Redirect("~/slot/" + id); + return this.Redirect(callbackUrl); } [HttpGet("queue")] - public async Task QueueLevel([FromRoute] int id) + public async Task QueueLevel([FromRoute] int id, [FromQuery] string? callbackUrl) { + if (string.IsNullOrEmpty(callbackUrl)) + { + callbackUrl = "~/slot/" + id; + } + User? user = this.database.UserFromWebRequest(this.Request); if (user == null) return this.Redirect("~/login"); @@ -57,12 +77,17 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website await this.database.QueueLevel(user, queuedSlot); - return this.Redirect("~/slot/" + id); + return this.Redirect(callbackUrl); } [HttpGet("unqueue")] - public async Task UnqueueLevel([FromRoute] int id) + public async Task UnqueueLevel([FromRoute] int id, [FromQuery] string? callbackUrl) { + if (string.IsNullOrEmpty(callbackUrl)) + { + callbackUrl = "~/slot/" + id; + } + User? user = this.database.UserFromWebRequest(this.Request); if (user == null) return this.Redirect("~/login"); @@ -71,7 +96,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers.Website await this.database.UnqueueLevel(user, queuedSlot); - return this.Redirect("~/slot/" + id); + return this.Redirect(callbackUrl); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Pages/SlotsPage.cshtml b/ProjectLighthouse/Pages/SlotsPage.cshtml index 28bf3741..3c2cef23 100644 --- a/ProjectLighthouse/Pages/SlotsPage.cshtml +++ b/ProjectLighthouse/Pages/SlotsPage.cshtml @@ -50,26 +50,26 @@ { if (isHearted) { - + } else { - + } if (isQueued) { - + } else { - + }