Data being passed from PokemonSleep parent to PokemonTable child. Getting ready for PokemonBackground!
This commit is contained in:
parent
2e1063c741
commit
b6b4be9dbb
|
@ -0,0 +1,6 @@
|
||||||
|
namespace Portfolio.WebUI.Server.Components.Component
|
||||||
|
{
|
||||||
|
public partial class PokemonBackground
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using Portfolio.Domain.Features.Pokemon;
|
using Portfolio.Domain.Features.Pokemon;
|
||||||
|
|
||||||
|
@ -6,19 +7,18 @@ namespace Portfolio.WebUI.Server.Components.Component
|
||||||
{
|
{
|
||||||
public partial class PokemonTable
|
public partial class PokemonTable
|
||||||
{
|
{
|
||||||
|
[Parameter]
|
||||||
|
public List<Pokemon> AllPokemon { get; set; }
|
||||||
|
|
||||||
private List<Pokemon> pokemons = new List<Pokemon>();
|
private List<Pokemon> pokemons = new List<Pokemon>();
|
||||||
private Dictionary<int, bool> isShiny = new Dictionary<int, bool>();
|
private Dictionary<int, bool> isShiny = new Dictionary<int, bool>();
|
||||||
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override void OnParametersSet()
|
||||||
{
|
{
|
||||||
var result = await PokemonService.GetAllPokemonAsync();
|
if (AllPokemon != null) {
|
||||||
if (result is not null)
|
pokemons = AllPokemon.ToList();
|
||||||
{
|
|
||||||
pokemons = result;
|
|
||||||
pokemons.Sort((x, y) => x.PokemonId.CompareTo(y.PokemonId));
|
|
||||||
|
|
||||||
// Initialize dictionary with false (show base image first)
|
|
||||||
foreach (var pokemon in pokemons)
|
foreach (var pokemon in pokemons)
|
||||||
{
|
{
|
||||||
isShiny[pokemon.Id] = false;
|
isShiny[pokemon.Id] = false;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
@page "/pokemonsleep"
|
@page "/pokemonsleep"
|
||||||
|
|
||||||
|
@inject IPokemonService PokemonService
|
||||||
|
|
||||||
@attribute [StreamRendering]
|
@attribute [StreamRendering]
|
||||||
@rendermode InteractiveServer
|
@rendermode InteractiveServer
|
||||||
|
|
||||||
|
@ -11,6 +13,6 @@
|
||||||
|
|
||||||
<PokemonHeader />
|
<PokemonHeader />
|
||||||
|
|
||||||
<PokemonTable />
|
<PokemonTable AllPokemon="pokemons"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
|
@ -0,0 +1,23 @@
|
||||||
|
using Portfolio.Application.Services.PokemonService;
|
||||||
|
using Portfolio.Domain.Features.Pokemon;
|
||||||
|
|
||||||
|
namespace Portfolio.WebUI.Server.Components.Pages
|
||||||
|
{
|
||||||
|
public partial class PokemonSleep
|
||||||
|
{
|
||||||
|
public List<Pokemon> pokemons = new List<Pokemon>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue