SyncService + SyncPage added

This commit is contained in:
Iván Szabó
2025-02-06 14:46:31 +01:00
parent b5e5158f1e
commit b233347a7d
11 changed files with 159 additions and 25 deletions
+46 -9
View File
@@ -1,22 +1,59 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.DataLayer;
namespace WorkFlowCheck.MAUI.Services
{
public class SyncService: ISyncService
public class SyncService : BaseService, ISyncService
{
private readonly HttpClient _httpClient;
private readonly AppDbContext _dbContext;
public SyncService(HttpClient httpClient, AppDbContext dbContext)
public SyncService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext) : base(httpClient, configuration, dbContext)
{
_httpClient = httpClient;
_dbContext = dbContext;
}
public async Task SyncDatas()
{
await SyncCheckPoints();
}
public async Task SyncCheckPoints()
{
try
{
// Az API végpont meghatározása
string endpoint = $"{_httpClient.BaseAddress}api/Sync/GetAllCheckPoints";
// HTTP GET kérés küldése
var response = await _httpClient.GetFromJsonAsync<ApiResponseDTO<CheckPointListDTO>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
var checkPointList = await _dbContext.CheckPoints.ToListAsync();
var missingItems = response.Data.CheckPointList.Where(f => !checkPointList.Any(s => s.Id == f.Id)).ToList();
foreach (var item in missingItems) {
}
}
}
}
catch (Exception ex)
{
// Hiba visszaadása
}
}
}
}