Mapper NETMAUI-ba

This commit is contained in:
Iván Szabó
2025-02-06 16:06:09 +01:00
parent b233347a7d
commit ac80a8a9bb
6 changed files with 39 additions and 11 deletions
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
@@ -10,12 +11,13 @@ using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.DataLayer;
using WorkFlowCheck.MAUI.DataLayer.Entities;
namespace WorkFlowCheck.MAUI.Services
{
public class SyncService : BaseService, ISyncService
{
public SyncService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext) : base(httpClient, configuration, dbContext)
public SyncService(HttpClient httpClient, IConfiguration configuration, AppDbContext dbContext, IMapper mapper) : base(httpClient, configuration, dbContext, mapper)
{
}
@@ -39,14 +41,12 @@ namespace WorkFlowCheck.MAUI.Services
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) {
}
var missingCheckPoint = _mapper.Map<List<CheckPoint>>(missingItems);
_dbContext.CheckPoints.AddRange(missingCheckPoint);
await _dbContext.SaveChangesAsync();
}
}
}
catch (Exception ex)
{