53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Portfolio.Domain.Features.Pokemon;
|
|
|
|
namespace Portfolio.WebUI.Server.Components.Pages.Pokemon_Pages
|
|
{
|
|
public partial class PokemonView
|
|
{
|
|
[Parameter] public int Id { get; set; }
|
|
private Pokemon? _pokemon;
|
|
private Pokemon? _pokemonVariant;
|
|
private List<int> _pokemonIds;
|
|
private int? _nextPokemonId;
|
|
private int? _previousPokemonId;
|
|
private int? _variationPokemonId;
|
|
private int _currentIndex;
|
|
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
_pokemon = await PokemonService.GetPokemonByPokemonIdAsync(Id);
|
|
|
|
// These can be smart queries if your data is sorted by ID or by another property
|
|
_pokemonIds = await PokemonService.GetAllPokemonIdsAsync();
|
|
_currentIndex = _pokemonIds.IndexOf(_pokemon.PokemonId);
|
|
//Console.WriteLine(_currentIndex);
|
|
|
|
_nextPokemonId = await PokemonService.GetNextPokemonIdAsync(Id);
|
|
_previousPokemonId = await PokemonService.GetPreviousPokemonIdAsync(Id);
|
|
|
|
_variationPokemonId = await PokemonService.GetVariationPokemonIdAsync(Id);
|
|
if (_variationPokemonId != null)
|
|
{
|
|
Console.WriteLine(_variationPokemonId);
|
|
_pokemonVariant = await PokemonService.GetPokemonByIdAsync((int)_variationPokemonId);
|
|
Console.WriteLine(_pokemonVariant.VariationName);
|
|
}
|
|
}
|
|
|
|
private void NavigateToNext()
|
|
{
|
|
if (_nextPokemonId.HasValue)
|
|
Navigation.NavigateTo($"/pokemonsleep/pokemon/{_nextPokemonId.Value}");
|
|
}
|
|
|
|
private void NavigateToPrevious()
|
|
{
|
|
if (_previousPokemonId.HasValue)
|
|
Navigation.NavigateTo($"/pokemonsleep/pokemon/{_previousPokemonId.Value}");
|
|
}
|
|
|
|
}
|
|
}
|