@using Microsoft.EntityFrameworkCore @* ToListAsync extension method *@
@page "/customers/{country?}"
@inject INorthwindService service
Customers @(string.IsNullOrWhiteSpace(Country)
? "Worldwide" : "in " + Country)
@if (customers is null)
{
Loading...
}
else
{
| Id |
Company Name |
Address |
Phone |
|
@foreach (Customer c in customers)
{
| @c.CustomerId |
@c.CompanyName |
@c.Address
@c.City
@c.PostalCode
@c.Country
|
@c.Phone |
|
}
}
@code {
[Parameter]
public string? Country { get; set; }
private IEnumerable? customers;
protected override async Task OnParametersSetAsync()
{
if (string.IsNullOrWhiteSpace(Country))
{
customers = await service.GetCustomersAsync();
}
else
{
customers = await service.GetCustomersAsync(Country);
}
}
}