mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-05 18:22:27 +00:00
Add ability to create fake rooms and delete all rooms
This commit is contained in:
parent
643404a7b3
commit
c1e807b29a
2 changed files with 61 additions and 1 deletions
|
@ -0,0 +1,44 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Helpers;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers.Website.Debug;
|
||||
|
||||
[ApiController]
|
||||
[Route("debug/roomVisualizer")]
|
||||
public class RoomVisualizerController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
|
||||
public RoomVisualizerController(Database database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
[HttpGet("createFakeRoom")]
|
||||
public async Task<IActionResult> CreateFakeRoom()
|
||||
{
|
||||
#if !DEBUG
|
||||
return this.NotFound();
|
||||
#else
|
||||
List<User> users = await this.database.Users.OrderByDescending(_ => EF.Functions.Random()).Take(2).ToListAsync();
|
||||
RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2);
|
||||
return this.Redirect("/debug/roomVisualizer");
|
||||
#endif
|
||||
}
|
||||
|
||||
[HttpGet("deleteRooms")]
|
||||
public IActionResult DeleteRooms()
|
||||
{
|
||||
#if !DEBUG
|
||||
return this.NotFound();
|
||||
#else
|
||||
RoomHelper.Rooms.RemoveAll(_ => true);
|
||||
return this.Redirect("/debug/roomVisualizer");
|
||||
#endif
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue