CheckListTemplateHeader klónozása
This commit is contained in:
@@ -24,7 +24,7 @@ namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
public class CheckListService : BaseService, ICheckListService
|
||||
{
|
||||
|
||||
|
||||
private readonly INumberGeneratorService _numberGeneratorService;
|
||||
|
||||
public CheckListService(AppDbContext dbContext,
|
||||
@@ -377,7 +377,7 @@ namespace WorkFlowCheck.BL.Services
|
||||
{
|
||||
checkListHeader.CheckStatus = CheckStatus.Closed;
|
||||
checkListHeader.IsEditable = false;
|
||||
checkListHeader.AcceptUserId = closeCheckListHeaderCloseDTO.UserId;
|
||||
checkListHeader.AcceptUserId = closeCheckListHeaderCloseDTO.UserId;
|
||||
|
||||
Log.ForContext("TAG", "BusinessFlow").Warning($"Ellenőrzési lap lezárva: Ellenőrzés:{closeCheckListHeaderCloseDTO.Id}, " +
|
||||
$"Felhasználó:{closeCheckListHeaderCloseDTO.UserId}, " +
|
||||
@@ -394,7 +394,7 @@ namespace WorkFlowCheck.BL.Services
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
public async Task<CheckListTemplateHeaderDTO> GetCheckListTemplateHeaderAsync(int Id)
|
||||
{
|
||||
var retVal = new CheckListTemplateHeaderDTO()
|
||||
@@ -491,7 +491,53 @@ namespace WorkFlowCheck.BL.Services
|
||||
}
|
||||
public async Task<bool> DeleteCheckListTemplateHeaderAsync(int id)
|
||||
{
|
||||
return await DeleteEntityByIdAsync<CheckListTemplateHeader>(id);
|
||||
return await DeleteEntityByIdAsync<CheckListTemplateHeader>(id);
|
||||
}
|
||||
public async Task<bool> CloneCheckListTemplateHeaderAsync(int id)
|
||||
{
|
||||
var retVal = false;
|
||||
try
|
||||
{
|
||||
var checkListTemplateHeader = await _dbContext.CheckListTemplateHeaders
|
||||
.Include(i => i.CheckListTemplateRows)
|
||||
.Where(w => w.Id == id).FirstOrDefaultAsync();
|
||||
if (checkListTemplateHeader != null)
|
||||
{
|
||||
|
||||
var newCheckListTemplateHeader = new CheckListTemplateHeader()
|
||||
{
|
||||
CheckListTemplateRows = new List<CheckListTemplateRow>(),
|
||||
Description = checkListTemplateHeader.Description,
|
||||
IsDeleted = false,
|
||||
NumberGenerator1Id = checkListTemplateHeader.NumberGenerator1Id,
|
||||
NumberGenerator2Id = checkListTemplateHeader.NumberGenerator2Id,
|
||||
ShortName = $"{checkListTemplateHeader.ShortName} (másolat)",
|
||||
};
|
||||
foreach (var checkListTemplateRow in checkListTemplateHeader.CheckListTemplateRows)
|
||||
{
|
||||
var newCheckListTemplateRow = new CheckListTemplateRow()
|
||||
{
|
||||
AnswerType = checkListTemplateRow.AnswerType,
|
||||
CheckListTemplateHeader = newCheckListTemplateHeader,
|
||||
CheckPointId = checkListTemplateRow.CheckPointId,
|
||||
EquipmentId = checkListTemplateRow.EquipmentId,
|
||||
IsDeleted = false,
|
||||
OperationDescription = checkListTemplateRow.OperationDescription,
|
||||
RowIndex = checkListTemplateRow.RowIndex,
|
||||
};
|
||||
newCheckListTemplateHeader.CheckListTemplateRows.Add(newCheckListTemplateRow);
|
||||
}
|
||||
_dbContext.CheckListTemplateHeaders.Add(newCheckListTemplateHeader);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
retVal = false;
|
||||
Log.ForContext("TAG", "BusinessFlow").Error(ex.Message);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
public async Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace WorkFlowCheck.BL.Services.Interfaces
|
||||
Task<List<CheckListTemplateHeaderDTO>> GetAllCheckListTemplateHeaderAsync();
|
||||
Task<CheckListTemplateHeaderDTO> UpdateCheckListTemplateHeaderAsync(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO);
|
||||
Task<bool> DeleteCheckListTemplateHeaderAsync(int id);
|
||||
Task<bool> CloneCheckListTemplateHeaderAsync(int id);
|
||||
Task<CheckListTemplateRowDTO> GetCheckListTemplateRowAsync(int id);
|
||||
Task<bool> DeleteCheckListTemplateRowAsync(int id);
|
||||
Task<CheckListTemplateRowDTO> UpdateCheckListTemplateRowAsync(CheckListTemplateRowDTO checkListTemplateRowDTO);
|
||||
|
||||
Reference in New Issue
Block a user