SyncCheckListTemplates implementálása
This commit is contained in:
@@ -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<CheckListTemplateRow> CheckListTemplateRows { get; set; } = new List<CheckListTemplateRow>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 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)
|
||||
///
|
||||
/// </summary>
|
||||
public string AnswerType { get; set; } = null!;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,12 @@ namespace WorkFlowCheck.MAUI.Mapper
|
||||
CreateMap<CheckPoint, CheckPointDTO>();
|
||||
CreateMap<CheckPointDTO, CheckPoint>();
|
||||
|
||||
CreateMap<CheckListTemplateHeaderDTO, CheckListTemplateHeader>()
|
||||
.ForMember(dest => dest.CheckListTemplateRows, opt => opt.MapFrom(src => src.CheckListTemplateRowDTO));
|
||||
CreateMap<CheckListTemplateHeader, CheckListTemplateHeaderDTO>()
|
||||
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
|
||||
CreateMap<CheckListTemplateRow, CheckListTemplateRowDTO>();
|
||||
CreateMap<CheckListTemplateRowDTO, CheckListTemplateRow>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>>(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<List<CheckListTemplateHeader>>(missingItems);
|
||||
|
||||
_dbContext.CheckListTemplateHeaders.AddRange(missingCheckListHeaders);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Hiba visszaadása
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user