fixes #5 : should block all possible attemps to delete order after locking

also redirects from edit page to list when locked
This commit is contained in:
Tea 2024-04-10 15:17:03 +02:00
parent b0d1d5c7cc
commit 157b426ce9
2 changed files with 21 additions and 2 deletions

View file

@ -61,6 +61,10 @@
{ {
<button @onclick="ShowDeleteConfirmation"> 🗑 Delete </button> <button @onclick="ShowDeleteConfirmation"> 🗑 Delete </button>
} }
else if (GlobalStuffService.OrdersLocked)
{
<p>Orders have been locked!</p>
}
else else
{ {
@ -166,6 +170,16 @@
{ {
Navigation.NavigateTo("/orderlist", true); Navigation.NavigateTo("/orderlist", true);
} }
EventHandler NavigateOnLock = async (sender, eventArgs) =>
{
if (GlobalStuffService.OrdersLocked)
{
Navigation.NavigateTo("/orderlist", true);
}
};
GlobalStuffService.OnLockOrMessageChange += NavigateOnLock;
} }
void FormSubmitted(EditContext editContext) void FormSubmitted(EditContext editContext)

View file

@ -128,6 +128,11 @@ namespace PizzaBot.Services
public void DeleteById(int id) public void DeleteById(int id)
{ {
if (_globalStuffService.OrdersLocked)
{
return;
}
var request = _context.Requests.Find(id); var request = _context.Requests.Find(id);
var result = _context.Results.Find(id); var result = _context.Results.Find(id);