From 3071ac7080ae92a1d8b661cf70a195fbf6cbeec8 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Tue, 11 Mar 2025 17:01:16 +0100 Subject: [PATCH] =?UTF-8?q?API=20m=C3=B3dos=C3=ADt=C3=A1sa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SyncController.cs | 24 +++++++++++++++++++ .../Services/Interfaces/ISyncService.cs | 1 + src/WorkFlowCheck.BL/Services/SyncService.cs | 23 ++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/WorkFlowCheck.API/Controllers/SyncController.cs b/src/WorkFlowCheck.API/Controllers/SyncController.cs index 1e1973a..8985703 100644 --- a/src/WorkFlowCheck.API/Controllers/SyncController.cs +++ b/src/WorkFlowCheck.API/Controllers/SyncController.cs @@ -39,6 +39,30 @@ namespace WorkFlowCheck.API.Controllers return retVal; } + [HttpGet("GetCheckPoints/{id}")] + public async Task> GetAllCheckpointsAsync(int id) + { + var retVal = new ApiResponseDTO() + { + IsSuccess = true, + }; + var checkPointListDTO = await _syncService.GetCheckPointAsync(id); + + if (checkPointListDTO != null) + { + + retVal.IsSuccess = true; + retVal.Data = checkPointListDTO; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } + [HttpGet("GetAllEquipments")] public async Task>> GetAllEquipmentsAsync() { diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs index e423133..50ab50e 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs @@ -6,6 +6,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces public interface ISyncService { Task> GetAllCheckPointAsync(); + Task GetCheckPointAsync(int id); Task> GetAllLocationAsync(); Task> GetAllEquipmentAsync(); diff --git a/src/WorkFlowCheck.BL/Services/SyncService.cs b/src/WorkFlowCheck.BL/Services/SyncService.cs index 112b928..57b4d55 100644 --- a/src/WorkFlowCheck.BL/Services/SyncService.cs +++ b/src/WorkFlowCheck.BL/Services/SyncService.cs @@ -43,6 +43,29 @@ namespace WorkFlowCheck.BL.Services return retVal; } + public async Task GetCheckPointAsync(int id) + { + var retVal = new CheckPointDTO(); + + try + { + var res = await _dbContext.CheckPoints + .Include(i => i.CheckListTemplateRows) + .Where(w => w.Id == id) + .AsNoTracking() + .FirstOrDefaultAsync(); + if (res != null) + { + retVal = _mapper.Map(res); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + + return retVal; + } public async Task> GetAllLocationAsync() { var retVal = new List();