API módosítása

This commit is contained in:
2025-03-11 17:01:26 +01:00
parent 8f9e5df847
commit 3071ac7080
3 changed files with 48 additions and 0 deletions
@@ -39,6 +39,30 @@ namespace WorkFlowCheck.API.Controllers
return retVal; return retVal;
} }
[HttpGet("GetCheckPoints/{id}")]
public async Task<ApiResponseDTO<CheckPointDTO>> GetAllCheckpointsAsync(int id)
{
var retVal = new ApiResponseDTO<CheckPointDTO>()
{
IsSuccess = true,
};
var checkPointListDTO = await _syncService.GetCheckPointAsync(id);
if (checkPointListDTO != null)
{
retVal.IsSuccess = true;
retVal.Data = checkPointListDTO;
}
else
{
retVal.IsSuccess = false;
retVal.Errors.Add("No data!");
}
return retVal;
}
[HttpGet("GetAllEquipments")] [HttpGet("GetAllEquipments")]
public async Task<ApiResponseDTO<List<EquipmentDTO>>> GetAllEquipmentsAsync() public async Task<ApiResponseDTO<List<EquipmentDTO>>> GetAllEquipmentsAsync()
{ {
@@ -6,6 +6,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces
public interface ISyncService public interface ISyncService
{ {
Task<List<CheckPointDTO>> GetAllCheckPointAsync(); Task<List<CheckPointDTO>> GetAllCheckPointAsync();
Task<CheckPointDTO> GetCheckPointAsync(int id);
Task<List<LocationDTO>> GetAllLocationAsync(); Task<List<LocationDTO>> GetAllLocationAsync();
Task<List<EquipmentDTO>> GetAllEquipmentAsync(); Task<List<EquipmentDTO>> GetAllEquipmentAsync();
@@ -43,6 +43,29 @@ namespace WorkFlowCheck.BL.Services
return retVal; return retVal;
} }
public async Task<CheckPointDTO> GetCheckPointAsync(int id)
{
var retVal = new CheckPointDTO();
try
{
var res = await _dbContext.CheckPoints
.Include(i => i.CheckListTemplateRows)
.Where(w => w.Id == id)
.AsNoTracking()
.FirstOrDefaultAsync();
if (res != null)
{
retVal = _mapper.Map<CheckPointDTO>(res);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<List<LocationDTO>> GetAllLocationAsync() public async Task<List<LocationDTO>> GetAllLocationAsync()
{ {
var retVal = new List<LocationDTO>(); var retVal = new List<LocationDTO>();