mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-16 02:01:28 +00:00
Implement deleting playlists
Also fixes playlists visually not updating in-game when modifying them
This commit is contained in:
parent
cd926a8415
commit
0b936d3e5d
1 changed files with 19 additions and 3 deletions
|
@ -15,11 +15,11 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
|
|||
[Authorize]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
public class CollectionController : ControllerBase
|
||||
public class PlaylistController : ControllerBase
|
||||
{
|
||||
private readonly DatabaseContext database;
|
||||
|
||||
public CollectionController(DatabaseContext database)
|
||||
public PlaylistController(DatabaseContext database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
@ -40,6 +40,22 @@ public class CollectionController : ControllerBase
|
|||
return this.Ok(new GenericSlotResponse(slots, total, 0));
|
||||
}
|
||||
|
||||
[HttpPost("playlists/{playlistId:int}/delete")]
|
||||
public async Task<IActionResult> DeletePlaylist(int playlistId)
|
||||
{
|
||||
GameTokenEntity token = this.GetToken();
|
||||
|
||||
PlaylistEntity? targetPlaylist = await this.database.Playlists.FirstOrDefaultAsync(p => p.PlaylistId == playlistId);
|
||||
if (targetPlaylist == null) return this.BadRequest();
|
||||
|
||||
if (token.UserId != targetPlaylist.CreatorId) return this.Unauthorized();
|
||||
|
||||
this.database.Playlists.Remove(targetPlaylist);
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
return this.Ok(await this.GetUserPlaylists(token.UserId));
|
||||
}
|
||||
|
||||
[HttpPost("playlists/{playlistId:int}")]
|
||||
[HttpPost("playlists/{playlistId:int}/slots")]
|
||||
[HttpPost("playlists/{playlistId:int}/slots/{slotId:int}/delete")]
|
||||
|
@ -90,7 +106,7 @@ public class CollectionController : ControllerBase
|
|||
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
return this.Ok(await this.GetUserPlaylists(token.UserId));
|
||||
return this.Ok(GamePlaylist.CreateFromEntity(targetPlaylist));
|
||||
}
|
||||
|
||||
private async Task<PlaylistResponse> GetUserPlaylists(int userId)
|
Loading…
Add table
Add a link
Reference in a new issue