From 5aae8fd067afeb44865d94c2a6bc85cf7308a770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Szab=C3=B3?= Date: Wed, 19 Feb 2025 16:23:34 +0100 Subject: [PATCH] =?UTF-8?q?SyncCheckListTemplates=20implement=C3=A1l=C3=A1?= =?UTF-8?q?sa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/CheckListTemplateHeader.cs | 3 +- .../Entities/CheckListTemplateRow.cs | 13 +++++++- .../Mapper/MapperProfile.cs | 6 ++++ .../Services/SyncService.cs | 31 +++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateHeader.cs b/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateHeader.cs index 70337bd..9f9dcb2 100644 --- a/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateHeader.cs +++ b/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateHeader.cs @@ -11,6 +11,7 @@ namespace WorkFlowCheck.MAUI.DataLayer.Entities public int Id { get; set; } public string ShortName { get; set; } = null!; public string Description { get; set; } = null!; - + public virtual ICollection CheckListTemplateRows { get; set; } = new List(); + } } diff --git a/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateRow.cs b/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateRow.cs index 052b0d1..7b43cf2 100644 --- a/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateRow.cs +++ b/src/WorkFlowCheck.MAUI/DataLayer/Entities/CheckListTemplateRow.cs @@ -17,6 +17,17 @@ namespace WorkFlowCheck.MAUI.DataLayer.Entities public int CheckPointId { get; set; } public virtual CheckPoint CheckPoint { get; set; } public string OperationDescription { get; set; } = null!; - + /// + /// + /// I-N (Igen, nem) + /// P (Fénykép készítése) + /// SI-N (Sárga igen,fehér nem) + /// I-SN (Fehér igen, sárga nem) + /// PI-N (Piros igen,fehér nem) + /// I-PN (Fehér igen, piros nem) + /// + /// + public string AnswerType { get; set; } = null!; + } } diff --git a/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs b/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs index 6fa42d2..624a391 100644 --- a/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs +++ b/src/WorkFlowCheck.MAUI/Mapper/MapperProfile.cs @@ -16,6 +16,12 @@ namespace WorkFlowCheck.MAUI.Mapper CreateMap(); CreateMap(); + CreateMap() + .ForMember(dest => dest.CheckListTemplateRows, opt => opt.MapFrom(src => src.CheckListTemplateRowDTO)); + CreateMap() + .ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows)); + CreateMap(); + CreateMap(); } } } diff --git a/src/WorkFlowCheck.MAUI/Services/SyncService.cs b/src/WorkFlowCheck.MAUI/Services/SyncService.cs index 6c6cd99..94ef58e 100644 --- a/src/WorkFlowCheck.MAUI/Services/SyncService.cs +++ b/src/WorkFlowCheck.MAUI/Services/SyncService.cs @@ -25,6 +25,7 @@ namespace WorkFlowCheck.MAUI.Services public async Task SyncDatas() { await SyncCheckPoints(); + await SyncCheckListTemplates(); } public async Task SyncCheckPoints() { @@ -56,5 +57,35 @@ namespace WorkFlowCheck.MAUI.Services } } + public async Task SyncCheckListTemplates() + { + try + { + // Az API végpont meghatározása + string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetAllCheckListHeader"; + + // HTTP GET kérés küldése + var response = await _httpClient.GetFromJsonAsync>>(endpoint); + if (response != null) + { + if (response.IsSuccess) + { + var checkPointList = await _dbContext.CheckListTemplateHeaders.ToListAsync(); + var missingItems = response.Data.Where(f => !checkPointList.Any(s => s.Id == f.Id)).ToList(); + + var missingCheckListHeaders = _mapper.Map>(missingItems); + + _dbContext.CheckListTemplateHeaders.AddRange(missingCheckListHeaders); + await _dbContext.SaveChangesAsync(); + } + } + } + catch (Exception ex) + { + // Hiba visszaadása + + } + } + } }