diff --git a/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncSrevice.cs b/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncSrevice.cs index b7109a60..ddaf30f8 100644 --- a/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncSrevice.cs +++ b/PARR.AIHITRelationshipsSyncer/Services/Implementations/RelationshipsSyncSrevice.cs @@ -91,18 +91,18 @@ namespace PARR.AIHITRelationshipsSyncer.Services.Implementations private async Task RemoveWasteRelationships(IEnumerable> 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)