@page "/"
<label for="Branch">Choose a Branch:</label>
<select Name="Branch" id="Branch" @bind="selectedBranch">
<option value="">---All Branches---</option>
@foreach (var item in branch)
{
<option value="@item.Id">@item.Description</option>
}
</select>
@code {
private string selectedBranch;
private FruitTable fruit = new FruitTable();
private List<FruitTable> fruits = new List<FruitTable>();
private List<FruitTable> FilteredFruits => string.IsNullOrEmpty(selectedBranch) ?
fruits.Where(s => s.Branch == selectedBranch).ToList() :
fruits;
private NewYearsPrices nyprices = new NewYearsPrices();
private List<NewYearsPrices> nyprice = new List<NewYearsPrices>();
private List<NewYearPrices> FilteredNewYearPrices => string.IsNullOrEmpty(selectedBranch) ?
nyprice.Where(s => s.Branch == selectedBranch).ToList() :
nyprice;
Branches branches = new Branches();
private List<Branches> branch = new List<Branches>();
protected override async Task OnInitializedAsync()
{
await Task.Delay(0);
GetFruitTable();
GetNewYearsPrices();
GetBranches();
}
private List<FruitTable> GetFruitTable()
{
fruits = fruitService.GetFruitTable();
return fruits;
}
private List<NewYearsPrices> GetNewYearsPrices()
{
nyprice = fruitService.GetNewYearsPrices();
return nyprice;
}
private List<Branches> GetBranches()
{
branch = fruitService.GetBranches();
return branch;
}
}