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 Portfolio.Domain.Features.Pokemon;
|
||||
|
||||
|
@ -6,19 +7,18 @@ namespace Portfolio.WebUI.Server.Components.Component
|
|||
{
|
||||
public partial class PokemonTable
|
||||
{
|
||||
[Parameter]
|
||||
public List<Pokemon> AllPokemon { get; set; }
|
||||
|
||||
private List<Pokemon> pokemons = new List<Pokemon>();
|
||||
private Dictionary<int, bool> isShiny = new Dictionary<int, bool>();
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
var result = await PokemonService.GetAllPokemonAsync();
|
||||
if (result is not null)
|
||||
{
|
||||
pokemons = result;
|
||||
pokemons.Sort((x, y) => x.PokemonId.CompareTo(y.PokemonId));
|
||||
if (AllPokemon != null) {
|
||||
pokemons = AllPokemon.ToList();
|
||||
|
||||
// Initialize dictionary with false (show base image first)
|
||||
foreach (var pokemon in pokemons)
|
||||
{
|
||||
isShiny[pokemon.Id] = false;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
@page "/pokemonsleep"
|
||||
|
||||
@inject IPokemonService PokemonService
|
||||
|
||||
@attribute [StreamRendering]
|
||||
@rendermode InteractiveServer
|
||||
|
||||
|
@ -11,6 +13,6 @@
|
|||
|
||||
<PokemonHeader />
|
||||
|
||||
<PokemonTable />
|
||||
<PokemonTable AllPokemon="pokemons"/>
|
||||
|
||||
</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