Open up new case page for moderators

This commit is contained in:
jvyden 2022-08-05 20:55:47 -04:00
commit d540a54cd8
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
6 changed files with 94 additions and 69 deletions

View file

@ -1,30 +0,0 @@
@page "/debug/newCase"
@using LBPUnion.ProjectLighthouse.Administration
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug.NewCasePage
@{
Layout = "Layouts/BaseLayout";
Model.Title = "DEBUG - New Case";
}
<form method="post">
@Html.AntiForgeryToken()
<label for="type">Case Type: </label>
<select name="type" id="type">
@foreach (CaseType type in Enum.GetValues<CaseType>())
{
<option value="@((int)type)">@type.ToString()</option>
}
</select><br/>
<label for="description">Description: </label>
<input type="text" name="description" id="description"/><br/>
<label for="expires">Expires: </label>
<input type="datetime-local" name="expires" id="expires"/><br/>
<label for="affected-id">Affected ID: </label>
<input type="number" name="affectedId" id="affected-id"/><br/>
<br/><input type="submit"/>
</form>

View file

@ -1,38 +0,0 @@
using System.Diagnostics;
using LBPUnion.ProjectLighthouse.Administration;
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug;
public class NewCasePage : BaseLayout
{
public NewCasePage(Database database) : base(database)
{}
public IActionResult OnGet() => this.Page();
public async Task<IActionResult> OnPost(
int type,
string description,
DateTime expires,
int affectedId
)
{
ModerationCase @case = new()
{
Type = (CaseType)type,
Reason = description,
ExpiresAt = expires,
CreatedAt = DateTime.Now,
CreatorId = 1,
AffectedId = affectedId,
};
this.Database.Cases.Add(@case);
await this.Database.SaveChangesAsync();
return this.Redirect("/moderation/cases/0");
}
}