IsTappable() Funktion eingebaut um zu prüfen, ob ein Cocktail aktuell mit der Maschine gezapft werden kann
This commit is contained in:
parent
25d38ee63d
commit
fc8ffecbd2
@ -12,19 +12,37 @@ namespace CocktailWeb.Pages
|
|||||||
private DbDataContext? _DataContext;
|
private DbDataContext? _DataContext;
|
||||||
|
|
||||||
private List<Cocktail> CocktailListe { get; set; } = new();
|
private List<Cocktail> CocktailListe { get; set; } = new();
|
||||||
|
private List<Filler>? MaschinenFiller;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
|
||||||
await ShowCocktails();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ShowCocktails()
|
|
||||||
{
|
{
|
||||||
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
_DataContext ??= await DataContextFactory.CreateDbContextAsync();
|
||||||
if (_DataContext != null)
|
if (_DataContext != null)
|
||||||
{
|
{
|
||||||
CocktailListe = await _DataContext.Cocktails.OrderBy(f => f.Name).ToListAsync();
|
MaschinenFiller = _DataContext.Fillers
|
||||||
|
.Include(f => f.Flasche)
|
||||||
|
.OrderBy(f => f.Pos).ToList();
|
||||||
|
CocktailListe = await _DataContext.Cocktails
|
||||||
|
.Include(c => c.Cocktailflaschen)
|
||||||
|
.ThenInclude(cf => cf.Flasche)
|
||||||
|
.OrderBy(c => c.Name)
|
||||||
|
.ToListAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prüft, ob der angegebene Cocktail aktuell machbar ist (true) oder ob mindestens eine Flasche nicht auf der Maschine fehlt (false)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cocktail"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool IsTappable(Cocktail cocktail)
|
||||||
|
{
|
||||||
|
if (MaschinenFiller != null)
|
||||||
|
{
|
||||||
|
return cocktail.Cocktailflaschen.All(cf => MaschinenFiller.Any(mf => mf.Flasche == cf.Flasche));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user