automatically rerenders orderlist when orders are balanced
This commit is contained in:
parent
02666f9d76
commit
c53289b218
2 changed files with 14 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
@inject PizzaDBService PizzaDBService
|
||||
@inject Microsoft.AspNetCore.Components.NavigationManager navigationManager
|
||||
@inject GlobalStuffService GlobalStuffService
|
||||
@rendermode InteractiveServer
|
||||
@attribute [StreamRendering]
|
||||
|
||||
<PageTitle>Pizza List</PageTitle>
|
||||
|
|
@ -118,4 +119,13 @@
|
|||
{
|
||||
navigationManager.NavigateTo($"/order/edit/{id}");
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
EventHandler Reload = async (sender, eventArgs) =>
|
||||
{
|
||||
await InvokeAsync(StateHasChanged);
|
||||
};
|
||||
PizzaDBService.OnBalanced += Reload;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ namespace PizzaBot.Services
|
|||
private PizzaRequestNameEqualityComparer _reqNameEqualityComparer = new PizzaRequestNameEqualityComparer();
|
||||
private Random _rnd = new Random();
|
||||
|
||||
public event EventHandler OnBalanced;
|
||||
|
||||
public PizzaDBService(PizzaContext context, PizzaBalancingService balancingService, GlobalStuffService globalStuffService)
|
||||
{
|
||||
_context = context;
|
||||
|
|
@ -230,6 +232,8 @@ namespace PizzaBot.Services
|
|||
_globalStuffService.TotalCost = balancingResult.totalCost;
|
||||
|
||||
_globalStuffService.ShouldBalance = false;
|
||||
|
||||
OnBalanced(this, null);
|
||||
}
|
||||
|
||||
public bool DeleteAllOrders(string passPhrase)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue