This commit is contained in:
maja
2026-10-28 18:09:30 +01:00
parent 9af3a94b0f
commit ab3b420953

View File

@@ -1,7 +1,40 @@
@page "/"
@using Microsoft.EntityFrameworkCore
@using Web_Jarmark.Data
@using Web_Jarmark.Data.Models
@inject ApplicationDbContext DbContext
<h3>Katalog</h3>
<h3>Katalog Produktů</h3>
<table class="table">
<thead>
<tr>
<th>Název</th>
<th>Kategorie</th>
<th>Cena</th>
<th>Stock</th>
</tr>
</thead>
<tbody>
@foreach (var product in products)
{
<tr>
<td>@product.Name</td>
<td>@product.Category.Name</td>
<td>@product.Price.ToString("C")</td>
<td>@product.StockQuantity</td>
</tr>
}
</tbody>
</table>
@code {
private List<Product> products;
protected override async Task OnInitializedAsync()
{
products = await DbContext.Products
.Include(p => p.Category)
.ToListAsync();
}
}