🐛 Fix magic spell and email service

This commit is contained in:
2025-04-29 21:52:35 +08:00
parent 0ebeab672b
commit 35792efa9f
10 changed files with 56 additions and 38 deletions

View 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();
}
}