From 157b426ce9d3db7570ce68b1f1ed8923f906ea38 Mon Sep 17 00:00:00 2001 From: Tea Date: Wed, 10 Apr 2024 15:17:03 +0200 Subject: [PATCH] fixes #5 : should block all possible attemps to delete order after locking also redirects from edit page to list when locked --- PizzaBot/Components/Pages/PizzaOrderEdit.razor | 18 ++++++++++++++++-- PizzaBot/Services/PizzaDBService.cs | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/PizzaBot/Components/Pages/PizzaOrderEdit.razor b/PizzaBot/Components/Pages/PizzaOrderEdit.razor index 9a8c9e8..393de45 100644 --- a/PizzaBot/Components/Pages/PizzaOrderEdit.razor +++ b/PizzaBot/Components/Pages/PizzaOrderEdit.razor @@ -61,6 +61,10 @@ { } + else if (GlobalStuffService.OrdersLocked) + { +

Orders have been locked!

+ } else { @@ -127,10 +131,10 @@ font-weight: 700; } - .priority-slider-container{ + .priority-slider-container { padding-bottom: 1rem; display: flex; - flex-direction:row; + flex-direction: row; align-items: center; gap: 1em; font-size: 0.75em; @@ -166,6 +170,16 @@ { Navigation.NavigateTo("/orderlist", true); } + + EventHandler NavigateOnLock = async (sender, eventArgs) => + { + if (GlobalStuffService.OrdersLocked) + { + Navigation.NavigateTo("/orderlist", true); + } + }; + + GlobalStuffService.OnLockOrMessageChange += NavigateOnLock; } void FormSubmitted(EditContext editContext) diff --git a/PizzaBot/Services/PizzaDBService.cs b/PizzaBot/Services/PizzaDBService.cs index b2e1f8e..126a0f7 100644 --- a/PizzaBot/Services/PizzaDBService.cs +++ b/PizzaBot/Services/PizzaDBService.cs @@ -128,6 +128,11 @@ namespace PizzaBot.Services public void DeleteById(int id) { + if (_globalStuffService.OrdersLocked) + { + return; + } + var request = _context.Requests.Find(id); var result = _context.Results.Find(id);