@inject HttpClient HttpClient

@Pizza.Special.Name

@Pizza.Special.Description
@(Pizza.Size)" (€@(Pizza.GetFormattedTotalPrice()))
@if (toppings == null) { } else if (Pizza.Toppings.Count >= 6) {
(maximale Anzahl erreicht)
} else { }
@foreach (var topping in Pizza.Toppings) {
@topping.Topping.Name @topping.Topping.GetFormattedPrice()
}
Kosten: @(Pizza.GetFormattedTotalPrice())
@code { List toppings; [Parameter] public Pizza Pizza { get; set; } [Parameter] public EventCallback OnCancel { get; set; } [Parameter] public EventCallback OnConfirm { get; set; } protected async override Task OnInitializedAsync() { toppings = await HttpClient.GetFromJsonAsync>("toppings"); } void ToppingSelected(ChangeEventArgs e) { if (int.TryParse((string)e.Value, out var index) && index >= 0) { AddTopping(toppings[index]); } } void AddTopping(Topping topping) { if (Pizza.Toppings.Find(pt => pt.Topping == topping) == null) { Pizza.Toppings.Add(new PizzaTopping() { Topping = topping }); } } void RemoveTopping(Topping topping) { Pizza.Toppings.RemoveAll(pt => pt.Topping == topping); } }