cs11dotnet7/vscode/PracticalApps/Northwind.BlazorWasm/Client/Pages/EditCustomer.razor
2022-03-13 16:17:01 +00:00

32 lines
663 B
Plaintext

@page "/editcustomer/{customerid}"
@inject INorthwindService service
@inject NavigationManager navigation
<h3>Edit Customer</h3>
<CustomerDetail ButtonText="Update"
Customer="@customer"
OnValidSubmit="@Update" />
@code {
[Parameter]
public string CustomerId { get; set; } = null!;
private Customer? customer = new();
protected async override Task OnParametersSetAsync()
{
customer = await service.GetCustomerAsync(CustomerId);
}
private async Task Update()
{
if (customer is not null)
{
await service.UpdateCustomerAsync(customer);
}
navigation.NavigateTo("customers");
}
}