SyncController API

This commit is contained in:
2025-02-06 14:02:18 +01:00
parent 7570908177
commit b5e5158f1e
7 changed files with 135 additions and 0 deletions
@@ -0,0 +1,62 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Serilog;
using WorkFlowCheck.BL.Services.Interfaces;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.DL;
using WorkFlowCheck.DL.Entities;
namespace WorkFlowCheck.BL.Services
{
public class SyncService : ISyncService
{
private AppDbContext _dbContext;
private IMapper _mapper;
public SyncService(AppDbContext dbContext, IMapper mapper)
{
_dbContext = dbContext;
_mapper = mapper;
}
public async Task<CheckPointListDTO> GetAllCheckPoint()
{
var retVal = new CheckPointListDTO();
try
{
var res = await _dbContext.CheckPoints.ToListAsync();
if (res != null)
{
retVal.CheckPointList = _mapper.Map<List<CheckPointDTO>>(res);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<CheckPointListDTO> GetAllLocation()
{
var retVal = new CheckPointListDTO();
try
{
var res = await _dbContext.CheckPoints.ToListAsync();
if (res != null)
{
retVal.CheckPointList = _mapper.Map<List<CheckPointDTO>>(res);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
}
}