86 lines
3.1 KiB
Plaintext
86 lines
3.1 KiB
Plaintext
@page "/cocktails/{CocktailId}"
|
|
@using CocktailWeb.Data
|
|
@using Microsoft.AspNetCore.Components.Sections
|
|
@using Microsoft.EntityFrameworkCore
|
|
@inject IDbContextFactory<DbDataContext> DataContextFactory;
|
|
|
|
|
|
<SectionContent SectionId="TopRow.Title">
|
|
<a class="btn btn-primary" href="/cocktails">
|
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left-circle" viewBox="0 0 16 16">
|
|
<path fill-rule="evenodd" d="M1 8a7 7 0 1 0 14 0A7 7 0 0 0 1 8m15 0A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-4.5-.5a.5.5 0 0 1 0 1H5.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L5.707 7.5z" />
|
|
</svg>
|
|
Zurück
|
|
</a>
|
|
</SectionContent>
|
|
|
|
@if (SelectedCocktail == null)
|
|
{
|
|
<h3>Cocktail konnte nicht gefunden werden</h3>
|
|
}
|
|
else
|
|
{
|
|
<div class="card mb-3" style="max-width: 540px;">
|
|
<div class="row g-0">
|
|
<div class="col-md-4">
|
|
<img src="@SelectedCocktail.ImageURL" class="img-fluid rounded-start" alt="...">
|
|
</div>
|
|
<div class="col-md-8">
|
|
<div class="card-body">
|
|
<h5 class="card-title">@SelectedCocktail.Name</h5>
|
|
<p class="card-text">
|
|
<h6>Zutaten:</h6>
|
|
<ul>
|
|
@foreach (var Zutat in SelectedCocktail.Cocktailflaschen.OrderBy(f => f.Reihenfolge))
|
|
{
|
|
@if (MaschinenFiller != null && MaschinenFiller.Exists(f => f.Flasche == Zutat.Flasche))
|
|
{
|
|
<li>@Zutat.Flasche?.Name (@Zutat.Menge ml)</li>
|
|
}
|
|
else
|
|
{
|
|
@* Zutat nicht in MaschinenFiller gefunden - Daher ist Maschine nicht damit bestückt*@
|
|
<li class="text-danger">@Zutat.Flasche?.Name (@Zutat.Menge ml) (nicht geladen)</li>
|
|
}
|
|
}
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@if (ValideMische)
|
|
{
|
|
<button class="btn btn-primary">Lets goooooo!</button>
|
|
} else
|
|
{
|
|
<button class="btn btn-outline-primary">Lets goooooo!</button>
|
|
}
|
|
}
|
|
|
|
|
|
@code {
|
|
[Parameter]
|
|
public string? CocktailId { get; set; }
|
|
private DbDataContext? _DataContext;
|
|
private Cocktail? SelectedCocktail;
|
|
private List<Filler>? MaschinenFiller;
|
|
|
|
private bool ValideMische = true;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
int id = Convert.ToInt32(CocktailId);
|
|
|
|
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
|
if (_DataContext != null)
|
|
{
|
|
SelectedCocktail = _DataContext.Cocktails.Include(c => c.Cocktailflaschen).ThenInclude(cf => cf.Flasche).Single(c => c.Id == id);
|
|
MaschinenFiller = _DataContext.Fillers.Include(f => f.Flasche).OrderBy(f => f.Pos).ToList();
|
|
}
|
|
|
|
}
|
|
|
|
}
|