mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 16:08:38 +00:00
Add page to become a pirate
This commit is contained in:
parent
5fdb9b4f5c
commit
77a2d27f13
7 changed files with 106 additions and 8 deletions
|
@ -52,6 +52,8 @@ public class BaseLayout : PageModel
|
|||
{
|
||||
if (ServerStatics.IsUnitTesting) return LocalizationManager.DefaultLang;
|
||||
if (this.language != null) return this.language;
|
||||
|
||||
if (this.User?.IsAPirate ?? false) return "en-PT";
|
||||
|
||||
IRequestCultureFeature? requestCulture = Request.HttpContext.Features.Get<IRequestCultureFeature>();
|
||||
if (requestCulture == null) return this.language = LocalizationManager.DefaultLang;
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
@page "/pirate"
|
||||
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.PirateSignupPage
|
||||
|
||||
@{
|
||||
Layout = "Layouts/BaseLayout";
|
||||
Model.Title = "ARRRRRRRRRR!";
|
||||
}
|
||||
<!--suppress GrazieInspection -->
|
||||
|
||||
@if (!Model.User!.IsAPirate)
|
||||
{
|
||||
<p>So, ye wanna be a pirate? Well, ye came to the right place!</p>
|
||||
<p>Just click this 'ere button, and welcome aboard!</p>
|
||||
<p>If you ever wanna walk the plank, come back 'ere.</p>
|
||||
|
||||
<form method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="submit" class="ui blue button" value="Aye aye, captain!"/>
|
||||
</form>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Back so soon, aye?</p>
|
||||
<p>If you're gonna walk the plank, then do it!</p>
|
||||
|
||||
<form method="post">
|
||||
@Html.AntiForgeryToken()
|
||||
<input type="submit" class="ui red button" value="Walk the plank"/>
|
||||
</form>
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using LBPUnion.ProjectLighthouse.PlayerData.Profiles;
|
||||
using LBPUnion.ProjectLighthouse.Servers.Website.Pages.Layouts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.Website.Pages;
|
||||
|
||||
public class PirateSignupPage : BaseLayout
|
||||
{
|
||||
public PirateSignupPage(Database database) : base(database)
|
||||
{}
|
||||
|
||||
public async Task<IActionResult> OnGet()
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.RedirectToPage("/login");
|
||||
|
||||
return this.Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPost()
|
||||
{
|
||||
User? user = this.Database.UserFromWebRequest(this.Request);
|
||||
if (user == null) return this.Redirect("/login");
|
||||
|
||||
user.IsAPirate = !user.IsAPirate;
|
||||
await this.Database.SaveChangesAsync();
|
||||
|
||||
return this.Redirect("/");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue