💄 Restyled web pages
🧱 Add tailwindcss
This commit is contained in:
@ -8,23 +8,42 @@ namespace DysonNetwork.Sphere.Pages.Spell;
|
||||
|
||||
public class MagicSpellPage(AppDatabase db, MagicSpellService spells) : PageModel
|
||||
{
|
||||
[BindProperty]
|
||||
public MagicSpell? CurrentSpell { get; set; }
|
||||
|
||||
public bool IsSuccess { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetAsync(string spellWord)
|
||||
{
|
||||
spellWord = Uri.UnescapeDataString(spellWord);
|
||||
var now = SystemClock.Instance.GetCurrentInstant();
|
||||
var spell = await db.MagicSpells
|
||||
CurrentSpell = await db.MagicSpells
|
||||
.Where(e => e.Spell == spellWord)
|
||||
.Where(e => e.ExpiresAt == null || now < e.ExpiresAt)
|
||||
.Where(e => e.AffectedAt == null || now >= e.AffectedAt)
|
||||
.Include(e => e.Account)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
ViewData["Spell"] = spell;
|
||||
|
||||
if (spell is not null)
|
||||
{
|
||||
await spells.ApplyMagicSpell(spell);
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostAsync()
|
||||
{
|
||||
if (CurrentSpell?.Id == null)
|
||||
return Page();
|
||||
|
||||
var now = SystemClock.Instance.GetCurrentInstant();
|
||||
var spell = await db.MagicSpells
|
||||
.Where(e => e.Id == CurrentSpell.Id)
|
||||
.Where(e => e.ExpiresAt == null || now < e.ExpiresAt)
|
||||
.Where(e => e.AffectedAt == null || now >= e.AffectedAt)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (spell == null)
|
||||
return Page();
|
||||
|
||||
await spells.ApplyMagicSpell(spell);
|
||||
IsSuccess = true;
|
||||
return Page();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user