mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2025-12-06 05:32:03 +01:00
77 lines
1.6 KiB
Plaintext
77 lines
1.6 KiB
Plaintext
@using Microsoft.EntityFrameworkCore @* ToListAsync extension method *@
|
|
@page "/customers/{country?}"
|
|
@inject INorthwindService service
|
|
|
|
<h3>
|
|
Customers @(string.IsNullOrWhiteSpace(Country)
|
|
? "Worldwide" : "in " + Country)
|
|
</h3>
|
|
|
|
<div class="form-group">
|
|
<a class="btn btn-info" href="createcustomer">
|
|
<i class="oi oi-plus"></i> Create New</a>
|
|
</div>
|
|
|
|
@if (customers is null)
|
|
{
|
|
<p><em>Loading...</em></p>
|
|
}
|
|
else
|
|
{
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th>Id</th>
|
|
<th>Company Name</th>
|
|
<th>Address</th>
|
|
<th>Phone</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (Customer c in customers)
|
|
{
|
|
<tr>
|
|
<td>@c.CustomerId</td>
|
|
<td>@c.CompanyName</td>
|
|
<td>
|
|
@c.Address<br />
|
|
@c.City<br />
|
|
@c.PostalCode<br />
|
|
@c.Country
|
|
</td>
|
|
<td>@c.Phone</td>
|
|
<td>
|
|
<a class="btn btn-info" href="editcustomer/@c.CustomerId">
|
|
<i class="oi oi-pencil"></i>
|
|
</a>
|
|
<a class="btn btn-danger"
|
|
href="deletecustomer/@c.CustomerId">
|
|
<i class="oi oi-trash"></i>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
|
|
@code {
|
|
[Parameter]
|
|
public string? Country { get; set; }
|
|
|
|
private IEnumerable<Customer>? customers;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(Country))
|
|
{
|
|
customers = await service.GetCustomersAsync();
|
|
}
|
|
else
|
|
{
|
|
customers = await service.GetCustomersAsync(Country);
|
|
}
|
|
}
|
|
}
|