ISyncService bővítése
This commit is contained in:
@@ -16,9 +16,9 @@ namespace WorkFlowCheck.API.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("GetAllCheckPoints")]
|
||||
public async Task<ApiResponseDTO<CheckPointListDTO>> GetAllCheckpoint()
|
||||
public async Task<ApiResponseDTO<List<CheckPointDTO>>> GetAllCheckpointsAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<CheckPointListDTO>()
|
||||
var retVal = new ApiResponseDTO<List<CheckPointDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
@@ -39,8 +39,56 @@ namespace WorkFlowCheck.API.Controllers
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetAllCheckListHeader")]
|
||||
public async Task<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>> GetAllCheckListHeader()
|
||||
[HttpGet("GetAllEquipments")]
|
||||
public async Task<ApiResponseDTO<List<EquipmentDTO>>> GetAllEquipmentsAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<EquipmentDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var equipmentListDTO = await _syncService.GetAllEquipmentAsync();
|
||||
|
||||
if (equipmentListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = equipmentListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetAllLocations")]
|
||||
public async Task<ApiResponseDTO<List<LocationDTO>>> GetAllLocationsAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<LocationDTO>>()
|
||||
{
|
||||
IsSuccess = true,
|
||||
};
|
||||
var locationListDTO = await _syncService.GetAllLocationAsync();
|
||||
|
||||
if (locationListDTO != null)
|
||||
{
|
||||
|
||||
retVal.IsSuccess = true;
|
||||
retVal.Data = locationListDTO;
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal.IsSuccess = false;
|
||||
retVal.Errors.Add("No data!");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[HttpGet("GetAllCheckListTemplateHeader")]
|
||||
public async Task<ApiResponseDTO<List<CheckListTemplateHeaderDTO>>> GetAllCheckListTemplateHeaderAsync()
|
||||
{
|
||||
var retVal = new ApiResponseDTO<List<CheckListTemplateHeaderDTO>>()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace WorkFlowCheck.BL.Mappings
|
||||
.ForMember(dest => dest.CheckListTemplateRowDTO, opt => opt.MapFrom(src => src.CheckListTemplateRows));
|
||||
CreateMap<CheckListTemplateRow, CheckListTemplateRowDTO>();
|
||||
CreateMap<CheckPoint, CheckPointDTO>();
|
||||
CreateMap<Location, LocationDTO>();
|
||||
CreateMap<Equipment, EquipmentDTO>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
{
|
||||
public interface ISyncService
|
||||
{
|
||||
Task<CheckPointListDTO> GetAllCheckPointAsync();
|
||||
Task<List<CheckPointDTO>> GetAllCheckPointAsync();
|
||||
Task<List<LocationDTO>> GetAllLocationAsync();
|
||||
Task<List<EquipmentDTO>> GetAllEquipmentAsync();
|
||||
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
using System.Collections.Generic;
|
||||
using WorkFlowCheck.BL.Services.Interfaces;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.DL;
|
||||
@@ -20,16 +21,54 @@ namespace WorkFlowCheck.BL.Services
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<CheckPointListDTO> GetAllCheckPointAsync()
|
||||
public async Task<List<CheckPointDTO>> GetAllCheckPointAsync()
|
||||
{
|
||||
var retVal = new CheckPointListDTO();
|
||||
var retVal = new List<CheckPointDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.CheckPoints.ToListAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal.CheckPointList = _mapper.Map<List<CheckPointDTO>>(res);
|
||||
retVal = _mapper.Map<List<CheckPointDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<LocationDTO>> GetAllLocationAsync()
|
||||
{
|
||||
var retVal = new List<LocationDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.Locations.ToListAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<LocationDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<List<EquipmentDTO>> GetAllEquipmentAsync()
|
||||
{
|
||||
var retVal = new List<EquipmentDTO>();
|
||||
|
||||
try
|
||||
{
|
||||
var res = await _dbContext.Equipments.ToListAsync();
|
||||
if (res != null)
|
||||
{
|
||||
retVal = _mapper.Map<List<EquipmentDTO>>(res);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -60,24 +99,6 @@ namespace WorkFlowCheck.BL.Services
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class CheckPointListDTO
|
||||
{
|
||||
public List<CheckPointDTO> CheckPointList { get; set; } = new List<CheckPointDTO>();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class EquipmentDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShortName { get; set; } = null!;
|
||||
public string EquipmentNumber { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.DTO
|
||||
{
|
||||
public class LocationDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string FullName { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user