From 8adf4583ea8870cda0fd6afb21f3ffcc3d95a7f2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 14 Jun 2023 09:58:38 +0200 Subject: [PATCH] Update comportamento modifica modale della porta --- .../Controllers/WebDoorCreatorController.cs | 46 ------------------- .../Services/WebDoorCreatorService.cs | 16 ------- .../Components/DoorMan/DoorModal.razor | 12 ++--- .../Components/DoorMan/DoorModal.razor.cs | 13 +++--- .../Components/Gen/NavMenuHorizontal.razor | 22 ++++----- WebDoorCreator.UI/WebDoorCreator.UI.csproj | 2 +- 6 files changed, 22 insertions(+), 89 deletions(-) diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index c5ec902..fda235c 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -286,52 +286,6 @@ namespace WebDoorCreator.Data.Controllers return newId; } - /// - /// Adding or removing a single door - /// - /// Record id to edit or add - /// States if it has to be added or removing a door - /// - public async Task DoorModQty(int NewQty, int doorId, bool isAdd) - { - /* crea nuovo metodo per modifica singola quantità porta: DOORMODQTY */ - bool fatto = false; - //List dbResult = new List(); - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) - { - try - { - var currRec = localDbCtx - .DbSetDoor - .Where(x => x.DoorId == doorId) - .FirstOrDefault(); - if (currRec != null) //if is not null edit the record found - { - if (NewQty > 0) - { - currRec.Quantity = NewQty; - } - else if (isAdd) - { - currRec.Quantity = currRec.Quantity + 1; - } - else - { - currRec.Quantity = currRec.Quantity - 1; - } - localDbCtx.Entry(currRec).State = EntityState.Modified; - } - await localDbCtx.SaveChangesAsync(); - fatto = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione durante DoorModQty: {Environment.NewLine}{exc}"); - } - } - return fatto; - } - /// /// Delete doorOp instance /// diff --git a/WebDoorCreator.Data/Services/WebDoorCreatorService.cs b/WebDoorCreator.Data/Services/WebDoorCreatorService.cs index 1fcd47c..ab8d9d7 100644 --- a/WebDoorCreator.Data/Services/WebDoorCreatorService.cs +++ b/WebDoorCreator.Data/Services/WebDoorCreatorService.cs @@ -1242,22 +1242,6 @@ namespace WebDoorCreator.Data.Services return dbResult; } - /// - /// Adding or removing a single door - /// - /// Record id to edit or add - /// States if it has to be added or removing a door - /// - public async Task DoorModQty(int NewQty, int OrderId, int DoorId, bool isAdd) - { - var dbResult = await dbController.DoorModQty(NewQty, DoorId, isAdd); - // svuoto cache - await DoorFlushCache(DoorId); - await DoorOpFlushCache(DoorId); - await OrderDetailFlushCache(OrderId); - await OrdersFlushCache(); - return dbResult; - } /// /// Eliminazione DoorOP diff --git a/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor b/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor index bc3f96f..330f5af 100644 --- a/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor +++ b/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor @@ -28,7 +28,7 @@
- +
@@ -37,15 +37,9 @@
- @if (CurrDoorClone.Quantity == CurrDoor.Quantity && CurrDoor.Quantity > 1) - { - - } + - @if (CurrDoorClone.Quantity == CurrDoor.Quantity) - { - - } +
diff --git a/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor.cs b/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor.cs index ab80e88..3067e2b 100644 --- a/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor.cs +++ b/WebDoorCreator.UI/Components/DoorMan/DoorModal.razor.cs @@ -102,14 +102,15 @@ namespace WebDoorCreator.UI.Components.DoorMan #region Protected Methods - protected async Task addOrRemoveOneDoorNumber(bool isAdd) + protected void modDoorQty(bool isAdd) { - //var door = new DoorModel(); - var done = await WDService.DoorModQty(0, CurrDoor.OrderId, CurrDoor.DoorId, isAdd); - if (done) + if (isAdd) { - //await E_isChange.InvokeAsync(true); - await ReloadData(); + DoorQty++; + } + else + { + DoorQty--; } } diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor index 2d686f0..96a24e8 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor @@ -3,7 +3,7 @@