mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-02 10:08:39 +00:00
Refactor LevelListController
This commit is contained in:
parent
e7d3d6bd02
commit
4248d79d99
2 changed files with 24 additions and 19 deletions
|
@ -12,12 +12,13 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||||
[Produces("text/xml")]
|
[Produces("text/xml")]
|
||||||
public class LevelListController : ControllerBase {
|
public class ListController : ControllerBase {
|
||||||
private readonly Database database;
|
private readonly Database database;
|
||||||
public LevelListController(Database database) {
|
public ListController(Database database) {
|
||||||
this.database = database;
|
this.database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Levels
|
||||||
#region Level Queue (lolcatftw)
|
#region Level Queue (lolcatftw)
|
||||||
|
|
||||||
[HttpGet("slots/lolcatftw/{username}")]
|
[HttpGet("slots/lolcatftw/{username}")]
|
||||||
|
@ -34,19 +35,6 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", 1));
|
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "total", 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("lolcatftw/remove/user/{id:int}")]
|
|
||||||
public async Task<IActionResult> RemoveQueuedLevel(int id) {
|
|
||||||
User? user = await this.database.UserFromRequest(this.Request);
|
|
||||||
if(user == null) return this.StatusCode(403, "");
|
|
||||||
|
|
||||||
QueuedLevel queuedLevel = await this.database.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.SlotId == id);
|
|
||||||
if(queuedLevel != null) this.database.QueuedLevels.Remove(queuedLevel);
|
|
||||||
|
|
||||||
await this.database.SaveChangesAsync();
|
|
||||||
|
|
||||||
return this.Ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("lolcatftw/add/user/{id:int}")]
|
[HttpPost("lolcatftw/add/user/{id:int}")]
|
||||||
public async Task<IActionResult> AddQueuedLevel(int id) {
|
public async Task<IActionResult> AddQueuedLevel(int id) {
|
||||||
User? user = await this.database.UserFromRequest(this.Request);
|
User? user = await this.database.UserFromRequest(this.Request);
|
||||||
|
@ -64,6 +52,19 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
|
|
||||||
return this.Ok();
|
return this.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("lolcatftw/remove/user/{id:int}")]
|
||||||
|
public async Task<IActionResult> RemoveQueuedLevel(int id) {
|
||||||
|
User? user = await this.database.UserFromRequest(this.Request);
|
||||||
|
if(user == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
QueuedLevel queuedLevel = await this.database.QueuedLevels.FirstOrDefaultAsync(q => q.UserId == user.UserId && q.SlotId == id);
|
||||||
|
if(queuedLevel != null) this.database.QueuedLevels.Remove(queuedLevel);
|
||||||
|
|
||||||
|
await this.database.SaveChangesAsync();
|
||||||
|
|
||||||
|
return this.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -85,7 +86,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("favourite/slot/user/{id:int}")]
|
[HttpPost("favourite/slot/user/{id:int}")]
|
||||||
public async Task<IActionResult> AddFavourite(int id) {
|
public async Task<IActionResult> AddFavouriteSlot(int id) {
|
||||||
User? user = await this.database.UserFromRequest(this.Request);
|
User? user = await this.database.UserFromRequest(this.Request);
|
||||||
if(user == null) return this.StatusCode(403, "");
|
if(user == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("unfavourite/slot/user/{id:int}")]
|
[HttpPost("unfavourite/slot/user/{id:int}")]
|
||||||
public async Task<IActionResult> RemoveFavourite(int id) {
|
public async Task<IActionResult> RemoveFavouriteSlot(int id) {
|
||||||
User? user = await this.database.UserFromRequest(this.Request);
|
User? user = await this.database.UserFromRequest(this.Request);
|
||||||
if(user == null) return this.StatusCode(403, "");
|
if(user == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
|
@ -116,6 +117,12 @@ namespace LBPUnion.ProjectLighthouse.Controllers {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
#endregion Levels
|
||||||
|
|
||||||
|
#region Users
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using LBPUnion.ProjectLighthouse.Types.Match;
|
using LBPUnion.ProjectLighthouse.Types.Match;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue