From 883ae6b845d4975329b201dd8616fbd7588e2298 Mon Sep 17 00:00:00 2001 From: ivanszabo Date: Thu, 27 Feb 2025 12:47:58 +0100 Subject: [PATCH] =?UTF-8?q?ISyncService=20b=C5=91v=C3=ADt=C3=A9se?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/SyncController.cs | 56 ++++++++++++++-- .../Mappings/MapperProfile.cs | 2 + .../Services/Interfaces/ISyncService.cs | 5 +- src/WorkFlowCheck.BL/Services/SyncService.cs | 65 ++++++++++++------- .../DTO/CheckPointListDTO.cs | 9 --- src/WorkFlowCheck.Common/DTO/EquipmentDTO.cs | 15 +++++ src/WorkFlowCheck.Common/DTO/LocationDTO.cs | 14 ++++ 7 files changed, 130 insertions(+), 36 deletions(-) delete mode 100644 src/WorkFlowCheck.Common/DTO/CheckPointListDTO.cs create mode 100644 src/WorkFlowCheck.Common/DTO/EquipmentDTO.cs create mode 100644 src/WorkFlowCheck.Common/DTO/LocationDTO.cs diff --git a/src/WorkFlowCheck.API/Controllers/SyncController.cs b/src/WorkFlowCheck.API/Controllers/SyncController.cs index f30248e..1e1973a 100644 --- a/src/WorkFlowCheck.API/Controllers/SyncController.cs +++ b/src/WorkFlowCheck.API/Controllers/SyncController.cs @@ -16,9 +16,9 @@ namespace WorkFlowCheck.API.Controllers } [HttpGet("GetAllCheckPoints")] - public async Task> GetAllCheckpoint() + public async Task>> GetAllCheckpointsAsync() { - var retVal = new ApiResponseDTO() + var retVal = new ApiResponseDTO>() { IsSuccess = true, }; @@ -38,9 +38,57 @@ namespace WorkFlowCheck.API.Controllers return retVal; } + + [HttpGet("GetAllEquipments")] + public async Task>> GetAllEquipmentsAsync() + { + var retVal = new ApiResponseDTO>() + { + IsSuccess = true, + }; + var equipmentListDTO = await _syncService.GetAllEquipmentAsync(); - [HttpGet("GetAllCheckListHeader")] - public async Task>> GetAllCheckListHeader() + if (equipmentListDTO != null) + { + + retVal.IsSuccess = true; + retVal.Data = equipmentListDTO; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } + + [HttpGet("GetAllLocations")] + public async Task>> GetAllLocationsAsync() + { + var retVal = new ApiResponseDTO>() + { + IsSuccess = true, + }; + var locationListDTO = await _syncService.GetAllLocationAsync(); + + if (locationListDTO != null) + { + + retVal.IsSuccess = true; + retVal.Data = locationListDTO; + } + else + { + retVal.IsSuccess = false; + retVal.Errors.Add("No data!"); + } + + return retVal; + } + + [HttpGet("GetAllCheckListTemplateHeader")] + public async Task>> GetAllCheckListTemplateHeaderAsync() { var retVal = new ApiResponseDTO>() { diff --git a/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs b/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs index 190c971..c85b48d 100644 --- a/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs +++ b/src/WorkFlowCheck.BL/Mappings/MapperProfile.cs @@ -23,6 +23,8 @@ namespace WorkFlowCheck.BL.Mappings .ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows)); CreateMap(); CreateMap(); + CreateMap(); + CreateMap(); } } } diff --git a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs index fb929bb..e423133 100644 --- a/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs +++ b/src/WorkFlowCheck.BL/Services/Interfaces/ISyncService.cs @@ -5,7 +5,10 @@ namespace WorkFlowCheck.BL.Services.Interfaces { public interface ISyncService { - Task GetAllCheckPointAsync(); + Task> GetAllCheckPointAsync(); + Task> GetAllLocationAsync(); + Task> GetAllEquipmentAsync(); + Task> GetAllCheckListTemplateAsync(); } } diff --git a/src/WorkFlowCheck.BL/Services/SyncService.cs b/src/WorkFlowCheck.BL/Services/SyncService.cs index 04c7d08..722c9a1 100644 --- a/src/WorkFlowCheck.BL/Services/SyncService.cs +++ b/src/WorkFlowCheck.BL/Services/SyncService.cs @@ -2,6 +2,7 @@ using AutoMapper; using Microsoft.EntityFrameworkCore; using Serilog; +using System.Collections.Generic; using WorkFlowCheck.BL.Services.Interfaces; using WorkFlowCheck.Common.DTO; using WorkFlowCheck.DL; @@ -20,16 +21,54 @@ namespace WorkFlowCheck.BL.Services _mapper = mapper; } - public async Task GetAllCheckPointAsync() + public async Task> GetAllCheckPointAsync() { - var retVal = new CheckPointListDTO(); + var retVal = new List(); try { var res = await _dbContext.CheckPoints.ToListAsync(); if (res != null) { - retVal.CheckPointList = _mapper.Map>(res); + retVal = _mapper.Map>(res); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + + return retVal; + } + public async Task> GetAllLocationAsync() + { + var retVal = new List(); + + try + { + var res = await _dbContext.Locations.ToListAsync(); + if (res != null) + { + retVal = _mapper.Map>(res); + } + } + catch (Exception ex) + { + Log.Error(ex.Message); + } + + return retVal; + } + public async Task> GetAllEquipmentAsync() + { + var retVal = new List(); + + try + { + var res = await _dbContext.Equipments.ToListAsync(); + if (res != null) + { + retVal = _mapper.Map>(res); } } catch (Exception ex) @@ -60,24 +99,6 @@ namespace WorkFlowCheck.BL.Services return retVal; } - public async Task GetAllLocation() - { - var retVal = new CheckPointListDTO(); - - try - { - var res = await _dbContext.CheckPoints.ToListAsync(); - if (res != null) - { - retVal.CheckPointList = _mapper.Map>(res); - } - } - catch (Exception ex) - { - Log.Error(ex.Message); - } - - return retVal; - } + } } diff --git a/src/WorkFlowCheck.Common/DTO/CheckPointListDTO.cs b/src/WorkFlowCheck.Common/DTO/CheckPointListDTO.cs deleted file mode 100644 index 88b1de8..0000000 --- a/src/WorkFlowCheck.Common/DTO/CheckPointListDTO.cs +++ /dev/null @@ -1,9 +0,0 @@ - -namespace WorkFlowCheck.Common.DTO -{ - public class CheckPointListDTO - { - public List CheckPointList { get; set; } = new List(); - - } -} diff --git a/src/WorkFlowCheck.Common/DTO/EquipmentDTO.cs b/src/WorkFlowCheck.Common/DTO/EquipmentDTO.cs new file mode 100644 index 0000000..c738bc6 --- /dev/null +++ b/src/WorkFlowCheck.Common/DTO/EquipmentDTO.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WorkFlowCheck.Common.DTO +{ + public class EquipmentDTO + { + public int Id { get; set; } + public string ShortName { get; set; } = null!; + public string EquipmentNumber { get; set; } = null!; + } +} diff --git a/src/WorkFlowCheck.Common/DTO/LocationDTO.cs b/src/WorkFlowCheck.Common/DTO/LocationDTO.cs new file mode 100644 index 0000000..6f4e74b --- /dev/null +++ b/src/WorkFlowCheck.Common/DTO/LocationDTO.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WorkFlowCheck.Common.DTO +{ + public class LocationDTO + { + public int Id { get; set; } + public string FullName { get; set; } = null!; + } +}