feat(aihitRelationshipsSyncer): refactoring
This commit is contained in:
@@ -91,18 +91,18 @@ namespace PARR.AIHITRelationshipsSyncer.Services.Implementations
|
||||
|
||||
private async Task RemoveWasteRelationships(IEnumerable<IGrouping<string?, AihitData>> groupedData)
|
||||
{
|
||||
var parentNames = groupedData.Select(t => t.Key);
|
||||
var parentNames = groupedData.Select(t => t.Key?.ToLower().Trim());
|
||||
|
||||
var units = await unitService.Get()
|
||||
.Include(t => t.ChildUnits).ToListAsync();
|
||||
|
||||
var parentsToDeleteChild = units.Where(t => parentNames.All(a => t.Name != a) && t.ChildUnits.Any());
|
||||
var parentsToDeleteChild = units.Where(t => parentNames.All(a => t.Name.ToLower() != a) && t.ChildUnits.Any());
|
||||
|
||||
if (parentsToDeleteChild.Any())
|
||||
{
|
||||
foreach (var unit in parentsToDeleteChild)
|
||||
{
|
||||
unit.ChildUnits.Clear();
|
||||
DeleteChilds(unit, unit.ChildUnits);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace PARR.AIHITRelationshipsSyncer.Services.Implementations
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
}
|
||||
);
|
||||
logger.LogInformation($"----- Создан связь Unit {unit.Name} - {childUnit.Name}-----");
|
||||
logger.LogInformation($"----- Создана связь Unit {unit.Name} - {childUnit.Name}-----");
|
||||
}
|
||||
|
||||
if (!isChanged)
|
||||
|
||||
Reference in New Issue
Block a user