From fa48365d989f21f4fe941fa2291393035456a2bb Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Thu, 3 Apr 2025 17:07:12 +0200 Subject: [PATCH] =?UTF-8?q?Egy=20kis=20lapoz=C3=A1s=20...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SyncController.cs | 69 +++++++++++++++++++ .../BaseStock/Locations/LocationsPage.cshtml | 21 +++++- .../Locations/LocationsPage.cshtml.cs | 5 ++ 3 files changed, 94 insertions(+), 1 deletion(-) diff --git a/src/WorkFlowCheck.API/Controllers/SyncController.cs b/src/WorkFlowCheck.API/Controllers/SyncController.cs index ca699e6..f9cef30 100644 --- a/src/WorkFlowCheck.API/Controllers/SyncController.cs +++ b/src/WorkFlowCheck.API/Controllers/SyncController.cs @@ -43,6 +43,29 @@ namespace WorkFlowCheck.API.Controllers return retVal; } + [HttpGet("DeleteCheckPoint/{id}")] + public async Task> DeleteCheckpointAsync(int id) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = true, + }; + var response = await _syncService.DeleteCheckPointAsync(id); + + if (response != null) + { + + retVal.IsSuccess = true; + retVal.Data = response; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } [HttpGet("GetAllCheckPoints")] public async Task>> GetAllCheckpointsAsync() { @@ -132,6 +155,29 @@ namespace WorkFlowCheck.API.Controllers return retVal; } + [HttpGet("DeleteEquipment/{id}")] + public async Task> DeleteEquipmentAsync(int id) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = true, + }; + var response = await _syncService.DeleteEquipmentAsync(id); + + if (response != null) + { + + retVal.IsSuccess = true; + retVal.Data = response; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } [HttpGet("GetAllEquipments")] public async Task>> GetAllEquipmentsAsync() { @@ -201,6 +247,29 @@ namespace WorkFlowCheck.API.Controllers return retVal; } + [HttpGet("DeleteLocation/{id}")] + public async Task> DeleteLocationAsync(int id) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = true, + }; + var response = await _syncService.DeleteLocationAsync(id); + + if (response != null) + { + + retVal.IsSuccess = true; + retVal.Data = response; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } [HttpGet("GetAllLocations")] public async Task>> GetAllLocationsAsync() { diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml index 27519c3..1f9e1e2 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml @@ -74,7 +74,26 @@ $('#tbLocationsPage').on('click', '.delete-btn', function () { const row = table.row($(this).closest('tr')).data(); - console.log(row); + + $.ajax({ + url: '/LocationsPage?handler=DeleteLocation', // A URL a handler-hez, ami az OnGetDeleteLocation metódust hívja + type: 'GET', // A kérés típusa, ebben az esetben GET + data: { id: 123 }, // Az id paraméter, amit átadsz + success: function (data) { + if (data.result) { + // A válaszban lévő result true, tehát sikeres volt a törlés + alert('Helyszín törölve!'); + } else { + alert('Hiba történt a törlés során.'); + } + }, + error: function (xhr, status, error) { + // Ha valami hiba történik a kérés során + alert('Hiba történt: ' + error); + } + }); + + showConfirmModal({ title: 'Törlés megerősítése', message: 'Biztosan törölni szeretnéd ezt az elemet?', diff --git a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml.cs b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml.cs index c2bdb1a..cf61d69 100644 --- a/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml.cs +++ b/src/WorkFlowCheck.Web/Pages/BaseStock/Locations/LocationsPage.cshtml.cs @@ -23,5 +23,10 @@ namespace WorkFlowCheck.Web.Pages.BaseStock.Locations var results = await _baseStockService.GetAllLocations(); return new JsonResult(new { data = results }); } + public async Task OnGetDeleteLocation(int id) + { + + return new JsonResult(new { result = true }); + } } }