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
@@ -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>();