@page "/pokemonsleep" @inject IPokemonService PokemonService @attribute [StreamRendering] @rendermode InteractiveServer Pokémon Sleep

Pokémon Sleep

Add New Pokemon
@if (pokemons == null) {

Loading...

} else {

Available Pokémon

@foreach (var pokemon in pokemons) { @if (pokemon.IsVariation) { string BaseURL = $"/pokemon_images/normal/{pokemon.PokemonId}-{pokemon.VariationName.ToLower()}{pokemon.PokemonName.ToLower()}.png"; string ShinyURL = $"/pokemon_images/shiny/{pokemon.PokemonId}-{pokemon.VariationName.ToLower()}{pokemon.PokemonName.ToLower()}.png"; } else // Base Case { string BaseURL = $"/pokemon_images/normal/{pokemon.PokemonId}.png"; ; string ShinyURL = $"/pokemon_images/shiny/{pokemon.PokemonId}.png"; } @if (pokemon.IsVariation) // If a Variant { @if (pokemon.VariationName == "Alolan") { } @if (pokemon.VariationName == "Paldean") { } } else // Otherwise, Base Case { } }
# Pokemon Sleep Type Speciality
@pokemon.PokemonId Alolan @pokemon.PokemonName Paldean @pokemon.PokemonName @pokemon.PokemonName @pokemon.SleepType @pokemon.Speciality
} @code { private List pokemons = new List(); private Dictionary isShiny = new Dictionary(); protected override async Task OnInitializedAsync() { var result = await PokemonService.GetAllPokemonAsync(); if (result is not null) { pokemons = result; pokemons.Sort((x,y) => x.PokemonId.CompareTo(y.PokemonId)); // Initialize dictionary with false (show base image first) foreach (var pokemon in pokemons) { isShiny[pokemon.PokemonId] = false; } } } private void ToggleImage(int pokemonId) { if (isShiny.ContainsKey(pokemonId)) { isShiny[pokemonId] = !isShiny[pokemonId]; } } }