Equipment is kész.

This commit is contained in:
2025-03-20 13:12:05 +01:00
parent bd60138a89
commit ae7ba2342e
19 changed files with 639 additions and 79 deletions
@@ -38,9 +38,11 @@ namespace WorkFlowCheck.BL.Mappings
CreateMap<CheckPointDTO, CheckPoint>();
CreateMap<Location, LocationDTO>();
CreateMap<LocationDTO, Location>();
CreateMap<Equipment, EquipmentDTO>();
CreateMap<EquipmentDTO, Equipment>();
CreateMap<CheckListHeader, CheckListHeaderDTO>()
.ForMember(dest => dest.CheckListRowDTO, opt => opt.MapFrom(src => src.CheckListRows));
}
@@ -160,7 +160,7 @@ namespace WorkFlowCheck.BL.Services
var res = await _dbContext.CheckListTemplateHeaders
.Where(w => w.Id == Id)
.Include(i => i.CheckListTemplateRows)
.ThenInclude(i=> i.CheckPoint)
.ThenInclude(i => i.CheckPoint)
.Include(i => i.CheckListTemplateRows)
.ThenInclude(i => i.Equipment)
.AsNoTracking()
@@ -210,7 +210,7 @@ namespace WorkFlowCheck.BL.Services
{
Description = checkListTemplateHeaderDTO.Description,
ShortName = checkListTemplateHeaderDTO.ShortName,
IsDeleted =false,
IsDeleted = false,
};
_dbContext.CheckListTemplateHeaders.Add(checkListTemplateHeader);
@@ -226,7 +226,7 @@ namespace WorkFlowCheck.BL.Services
if (checkListTemplateHeader != null)
{
checkListTemplateHeader.Description = checkListTemplateHeaderDTO.Description;
checkListTemplateHeader.ShortName = checkListTemplateHeaderDTO.ShortName;
checkListTemplateHeader.ShortName = checkListTemplateHeaderDTO.ShortName;
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<CheckListTemplateHeaderDTO>(checkListTemplateHeader);
@@ -247,8 +247,8 @@ namespace WorkFlowCheck.BL.Services
try
{
var res = await _dbContext.CheckListTemplateRows
.Include(i=> i.Equipment)
.Include(i=> i.CheckPoint)
.Include(i => i.Equipment)
.Include(i => i.CheckPoint)
.Where(w => w.Id == id)
.AsNoTracking()
.FirstOrDefaultAsync();
@@ -266,6 +266,52 @@ namespace WorkFlowCheck.BL.Services
return retVal;
}
public Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO) => throw new NotImplementedException();
public async Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO)
{
var retVal = new CheckListTemplateRowDTO() { };
try
{
if (checkListTemplateRowDTO.Id == 0)
{
var checkListTemplateRow = new CheckListTemplateRow()
{
CheckListTemplateHeaderId = checkListTemplateRowDTO.CheckListTemplateHeaderId,
CheckPointId = checkListTemplateRowDTO.CheckPointId,
EquipmentId = checkListTemplateRowDTO.EquipmentId,
OperationDescription = checkListTemplateRowDTO.OperationDescription,
AnswerType = checkListTemplateRowDTO.AnswerType,
RowIndex = checkListTemplateRowDTO.RowIndex,
};
_dbContext.CheckListTemplateRows.Add(checkListTemplateRow);
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<CheckListTemplateRowDTO>(checkListTemplateRow);
}
else
{
var checkListTemplateRow = await _dbContext.CheckListTemplateRows
.Where(w => w.Id == checkListTemplateRowDTO.Id)
.FirstOrDefaultAsync();
if (checkListTemplateRow != null)
{
checkListTemplateRow.CheckListTemplateHeaderId = checkListTemplateRowDTO.CheckListTemplateHeaderId;
checkListTemplateRow.CheckPointId = checkListTemplateRowDTO.CheckPointId;
checkListTemplateRow.EquipmentId = checkListTemplateRowDTO.EquipmentId;
checkListTemplateRow.OperationDescription = checkListTemplateRowDTO.OperationDescription;
checkListTemplateRow.AnswerType = checkListTemplateRowDTO.AnswerType;
checkListTemplateRow.RowIndex = checkListTemplateRowDTO.RowIndex;
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<CheckListTemplateRowDTO>(checkListTemplateRow);
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
}
}
@@ -8,8 +8,17 @@ namespace WorkFlowCheck.BL.Services.Interfaces
Task<List<CheckPointDTO>> GetAllCheckPointAsync();
Task<CheckPointDTO> GetCheckPointAsync(int id);
Task<CheckPointDTO> UpdateCheckPointAsync(CheckPointDTO checkPointDTO);
Task<List<LocationDTO>> GetAllLocationAsync();
Task<LocationDTO> GetLocationAsync(int id);
Task<LocationDTO> UpdateLocationAsync(LocationDTO LocationDTO);
Task<List<EquipmentDTO>> GetAllEquipmentAsync();
Task<EquipmentDTO> GetEquipmentAsync(int id);
Task<EquipmentDTO> UpdateEquipmentAsync(EquipmentDTO EquipmentDTO);
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync();
}
@@ -101,6 +101,9 @@ namespace WorkFlowCheck.BL.Services
return retVal;
}
public async Task<List<LocationDTO>> GetAllLocationAsync()
{
var retVal = new List<LocationDTO>();
@@ -120,6 +123,67 @@ namespace WorkFlowCheck.BL.Services
return retVal;
}
public async Task<LocationDTO> GetLocationAsync(int id)
{
var retVal = new LocationDTO();
try
{
var res = await _dbContext.Locations
.Where(w => w.Id == id)
.AsNoTracking()
.FirstOrDefaultAsync();
if (res != null)
{
retVal = _mapper.Map<LocationDTO>(res);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<LocationDTO> UpdateLocationAsync(LocationDTO LocationDTO)
{
var retVal = new LocationDTO();
try
{
if (LocationDTO.Id == 0) //Hozzáadás, ha Id == 0
{
var Location = _mapper.Map<Location>(LocationDTO);
_dbContext.Locations.Add(Location);
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<LocationDTO>(Location);
}
else
{
var res = await _dbContext.Locations.Where(w => w.Id == LocationDTO.Id).FirstOrDefaultAsync();
if (res != null)
{
res=_mapper.Map<Location>(LocationDTO);
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<LocationDTO>(res);
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<List<EquipmentDTO>> GetAllEquipmentAsync()
{
var retVal = new List<EquipmentDTO>();
@@ -139,6 +203,63 @@ namespace WorkFlowCheck.BL.Services
return retVal;
}
public async Task<EquipmentDTO> GetEquipmentAsync(int id)
{
var retVal = new EquipmentDTO();
try
{
var res = await _dbContext.Equipments
.Where(w => w.Id == id)
.AsNoTracking()
.FirstOrDefaultAsync();
if (res != null)
{
retVal = _mapper.Map<EquipmentDTO>(res);
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<EquipmentDTO> UpdateEquipmentAsync(EquipmentDTO EquipmentDTO)
{
var retVal = new EquipmentDTO();
try
{
if (EquipmentDTO.Id == 0) //Hozzáadás, ha Id == 0
{
var Equipment = _mapper.Map<Equipment>(EquipmentDTO);
_dbContext.Equipments.Add(Equipment);
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<EquipmentDTO>(Equipment);
}
else
{
var res = await _dbContext.Equipments.Where(w => w.Id == EquipmentDTO.Id).FirstOrDefaultAsync();
if (res != null)
{
res.ShortName = EquipmentDTO.ShortName;
res.EquipmentNumber = EquipmentDTO.EquipmentNumber;
await _dbContext.SaveChangesAsync();
retVal = _mapper.Map<EquipmentDTO>(res);
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
return retVal;
}
public async Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateAsync()
{
var retVal = new List<CheckListTemplateHeaderDTO>();