mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-04 09:58:22 +00:00
* Initial work for user settings page * Finish user setting and slot setting pages * Don't show slot upload date on home page and fix team pick redirection * Fix upload image button alignment on mobile * Fix image upload on iPhone * Remove unused css and add selected button color * Fix login email check and bump ChromeDriver to 105 * Remove duplicated code and allow users to leave fields empty * Add unpublish button on level settings and move settings button position * Don't show edit button on mini card * Self review bug fixes and users can no longer use an in-use email
61 lines
No EOL
2 KiB
C#
61 lines
No EOL
2 KiB
C#
#nullable enable
|
|
using LBPUnion.ProjectLighthouse.Levels;
|
|
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Servers.Website.Controllers.Admin;
|
|
|
|
[ApiController]
|
|
[Route("moderation/slot/{id:int}")]
|
|
public class ModerationSlotController : ControllerBase
|
|
{
|
|
private readonly Database database;
|
|
|
|
public ModerationSlotController(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.IsModerator) 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.Redirect("~/slot/" + id);
|
|
}
|
|
|
|
[HttpGet("removeTeamPick")]
|
|
public async Task<IActionResult> RemoveTeamPick([FromRoute] int id)
|
|
{
|
|
User? user = this.database.UserFromWebRequest(this.Request);
|
|
if (user == null || !user.IsModerator) 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.Redirect("~/slot/" + id);
|
|
}
|
|
|
|
[HttpGet("delete")]
|
|
public async Task<IActionResult> DeleteLevel([FromRoute] int id)
|
|
{
|
|
User? user = this.database.UserFromWebRequest(this.Request);
|
|
if (user == null || !user.IsModerator) 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.Redirect("~/slots/0");
|
|
}
|
|
} |