80 lines
2.9 KiB
Plaintext

@using Microsoft.AspNetCore.Components.Sections
@using Microsoft.EntityFrameworkCore
@using CocktailWeb.Data
@page "/settings/flaschen"
@inject IDbContextFactory<DbDataContext> FlascheDataContextFactory;
<PageTitle>Flaschen</PageTitle>
<SectionContent SectionId="TopRow.Title">
<label>Einstellungen - Zutaten</label>
</SectionContent>
@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">Hinzufügen</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>
}
@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)">Speichern</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)">Bearbeiten</button>
<button name="submit" type="submit" class="btn btn-primary" @onclick="() => DeleteFlasche(flasche)">Löschen</button>
</td>
</tr>
}
}
</tbody>
</table>
</div>
}
@code {
}