SyncController API
This commit is contained in:
@@ -14,6 +14,7 @@ namespace WorkFlowCheck.BL.Infra
|
||||
public static void DIInit(IServiceCollection service)
|
||||
{
|
||||
service.AddScoped<IUserService, UserService>();
|
||||
service.AddScoped<ISyncService, SyncService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ namespace WorkFlowCheck.BL.Mappings
|
||||
CreateMap<UserDTO, User>()
|
||||
.ForMember(dest => dest.PasswordHash, opt => opt.MapFrom<PasswordHashResolver>());
|
||||
|
||||
|
||||
CreateMap<CheckListTemplateHeader, CheckListTemplateHeaderDTO>();
|
||||
CreateMap<CheckPoint, CheckPointDTO>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
|
||||
|
||||
namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface ISyncService
|
||||
{
|
||||
Task<CheckPointListDTO> GetAllCheckPoint();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user