exciting-aftermath/Portfolio.WebUI.Server/Components/Pages/PokemonEdit.razor.cs

38 lines
944 B
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Portfolio.Domain.Features.Pokemon;
namespace Portfolio.WebUI.Server.Components.Pages
{
public partial class PokemonEdit
{
[Parameter] public int Id { get; set; }
private Pokemon? pokemon;
protected override async Task OnInitializedAsync()
{
pokemon = await PokemonService.GetPokemonByIdAsync(Id);
}
private async Task HandleSubmit()
{
await PokemonService.UpdatePokemonAsync(pokemon);
//Navigation.NavigateTo("/pokemonsleep");
await JSRuntime.InvokeVoidAsync("history.back");
}
private async void Cancel()
{
await JSRuntime.InvokeVoidAsync("history.back");
}
private bool HideLabel { get; set; } = true;
private void Toggle()
{
HideLabel = !HideLabel;
}
}
}