mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-06 02:32:28 +00:00
Add case generation
This commit is contained in:
parent
bc998b1ba9
commit
1eede416d4
4 changed files with 27 additions and 17 deletions
|
@ -1,66 +0,0 @@
|
|||
#nullable enable
|
||||
using LBPUnion.ProjectLighthouse.Levels;
|
||||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Types;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
||||
|
||||
[ApiController]
|
||||
[Route("admin/slot/{id:int}")]
|
||||
public class AdminSlotController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
|
||||
public AdminSlotController(Database database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
[HttpGet("teamPick")]
|
||||
public async Task<IActionResult> TeamPick([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.StatusCode(403, "");
|
||||
|
||||
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (slot == null) return this.NotFound();
|
||||
|
||||
slot.TeamPick = true;
|
||||
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
return this.Ok();
|
||||
}
|
||||
|
||||
[HttpGet("removeTeamPick")]
|
||||
public async Task<IActionResult> RemoveTeamPick([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.StatusCode(403, "");
|
||||
|
||||
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (slot == null) return this.NotFound();
|
||||
|
||||
slot.TeamPick = false;
|
||||
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
return this.Ok();
|
||||
}
|
||||
|
||||
[HttpGet("delete")]
|
||||
public async Task<IActionResult> DeleteLevel([FromRoute] int id)
|
||||
{
|
||||
User? user = this.database.UserFromWebRequest(this.Request);
|
||||
if (user == null || !user.IsAdmin) return this.StatusCode(403, "");
|
||||
|
||||
Slot? slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == id);
|
||||
if (slot == null) return this.Ok();
|
||||
|
||||
await this.database.RemoveSlot(slot);
|
||||
|
||||
return this.Ok();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue