🐛 Fix magic spell and email service
This commit is contained in:
92
DysonNetwork.Sphere/Pages/Spell/MagicSpellPage.cshtml
Normal file
92
DysonNetwork.Sphere/Pages/Spell/MagicSpellPage.cshtml
Normal file
@ -0,0 +1,92 @@
|
||||
@page "/spells/{spellWord}"
|
||||
@using DysonNetwork.Sphere.Account
|
||||
@model DysonNetwork.Sphere.Pages.Spell.MagicSpellPage
|
||||
|
||||
@{
|
||||
Layout = null;
|
||||
|
||||
var spell = ViewData["Spell"] as MagicSpell;
|
||||
}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Solar Network Magic Spell</title>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<style>
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #2d2d2d;
|
||||
font-family: "Roboto Mono", monospace;
|
||||
color: #c9d1d9;
|
||||
}
|
||||
|
||||
.parent {
|
||||
padding: 20px;
|
||||
max-width: 480px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 18px;
|
||||
font-weight: 300;
|
||||
color: #ffffff;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 20px;
|
||||
font-size: 11px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.footer-product {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="parent">
|
||||
<div class="container">
|
||||
<h1>Magic Spell</h1>
|
||||
@if (spell == null)
|
||||
{
|
||||
<div>
|
||||
<p style="color: yellow;">The spell was expired or not exists.</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>
|
||||
<p style="color: green;">The spell was applied successfully!</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="footer">
|
||||
<div class="footer-product">Solar Network</div>
|
||||
<a
|
||||
href="https://solsynth.dev"
|
||||
style="color: #c9d1d9; text-decoration: none"
|
||||
>Solsynth LLC</a>
|
||||
© @DateTime.Now.Year<br/>
|
||||
Powered by
|
||||
<a
|
||||
href="https://github.com/Solsynth/DysonNetwork"
|
||||
style="color: #c9d1d9"
|
||||
>DysonNetwork.Sphere</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
30
DysonNetwork.Sphere/Pages/Spell/MagicSpellPage.cshtml.cs
Normal file
30
DysonNetwork.Sphere/Pages/Spell/MagicSpellPage.cshtml.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using DysonNetwork.Sphere.Account;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NodaTime;
|
||||
|
||||
namespace DysonNetwork.Sphere.Pages.Spell;
|
||||
|
||||
public class MagicSpellPage(AppDatabase db, MagicSpellService spells) : PageModel
|
||||
{
|
||||
public async Task<IActionResult> OnGetAsync(string spellWord)
|
||||
{
|
||||
spellWord = Uri.UnescapeDataString(spellWord);
|
||||
var now = SystemClock.Instance.GetCurrentInstant();
|
||||
var spell = await db.MagicSpells
|
||||
.Where(e => e.Spell == spellWord)
|
||||
.Where(e => e.ExpiresAt == null || now < e.ExpiresAt)
|
||||
.Where(e => e.AffectedAt == null || now >= e.AffectedAt)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
ViewData["Spell"] = spell;
|
||||
|
||||
if (spell is not null)
|
||||
{
|
||||
await spells.ApplyMagicSpell(spell);
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user