Filter servers by city by adding functionality to buttons under city cards.
This commit is contained in:
parent
1d7bb19c40
commit
838fc29b51
@ -16,7 +16,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<img src=@($"/images/{@city}.png") class="card-img-top" alt="@city">
|
<img src=@($"/images/{@city}.png") class="card-img-top" alt="@city">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<button class="btn btn-primary">@city</button>
|
<button class="btn btn-primary" @onclick="@(() => { SelectCity(city); })">@city</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -54,6 +54,7 @@
|
|||||||
@code {
|
@code {
|
||||||
private List<string> cities = ServersRepository.GetCities();
|
private List<string> cities = ServersRepository.GetCities();
|
||||||
private List<Server> servers = ServersRepository.GetServersByCity("Eindhoven");
|
private List<Server> servers = ServersRepository.GetServersByCity("Eindhoven");
|
||||||
|
private string selectedCity = "Eindhoven";
|
||||||
|
|
||||||
private void DeleteServer(int serverId)
|
private void DeleteServer(int serverId)
|
||||||
{
|
{
|
||||||
@ -63,4 +64,10 @@
|
|||||||
NavigationManager.Refresh();
|
NavigationManager.Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SelectCity(string cityName)
|
||||||
|
{
|
||||||
|
this.selectedCity = cityName;
|
||||||
|
this.servers = ServersRepository.GetServersByCity(this.selectedCity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user