cocktailweb/CocktailWeb/Pages/Flaschen.razor
2024-01-15 19:02:47 +01:00

76 lines
2.7 KiB
Plaintext

@using Microsoft.EntityFrameworkCore
@using CocktailWeb.Data
@page "/flaschen"
@inject IDbContextFactory<DbDataContext> FlascheDataContextFactory;
<PageTitle>Flaschen</PageTitle>
@if (CreateFormVisible && FlascheToCreate != null)
{
<h3>Flasche hinzufügen</h3>
<div class="row">
<label for="Name" class="col-4 col-form-label">Name</label>
<div class="col-8">
<input id="Name" name="Name" type="text" class="form-control" @bind="@FlascheToCreate.Name" />
</div>
</div>
<div class="form-group row">
<div class="offset-4 col-8">
<button name="submit" type="submit" class="btn btn-primary" @onclick="CreateNewFlasche">Submit</button>
</div>
</div>
}
else
{
<div class="form-group row">
<div class="offset-4 col-8">
<button name="submit" type="submit" class="btn btn-primary" @onclick="ShowCreateForm">Flasche hinzufügen</button>
</div>
</div>
}
<h3>Flaschen</h3>
@if (FlaschenListe != null && FlaschenListe.Count > 0)
{
<div class="table-responsive">
<table class="table table-striped table-hover table-bordered table-light border-dark">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
@foreach (var flasche in FlaschenListe)
{
@if (EditFormVisible && FlascheToUpdate != null && FlascheToUpdate.Id == flasche.Id)
{
<tr>
<th scope="row">@FlascheToUpdate.Id</th>
<td> <input id="Name" name="Name" type="text" class="form-control" @bind="@FlascheToUpdate.Name" /></td>
<td><button name="submit" type="submit" class="btn btn-primary" @onclick="() => UpdateEmployee(FlascheToUpdate)">Save</button></td>
</tr>
}
else
{
<tr>
<th scope="row">@flasche.Id</th>
<td>@flasche.Name</td>
<td>
<button name="submit" type="submit" class="btn btn-primary" @onclick="() => ShowEditForm(flasche)">Edit</button>
<button name="submit" type="submit" class="btn btn-primary" @onclick="() => DeleteFlasche(flasche)">Delete</button>
</td>
</tr>
}
}
</tbody>
</table>
</div>
}
@code {
}