30 lines
749 B
C#
30 lines
749 B
C#
using GazpromApp.Models;
|
|
using System.Linq;
|
|
|
|
namespace GazpromApp.Utils;
|
|
|
|
public static class PropertyParentHelper
|
|
{
|
|
public static void SetPropertyParents(this Point point)
|
|
{
|
|
foreach (var prop in point.Properties)
|
|
{
|
|
SetParentsRecursively(prop);
|
|
}
|
|
|
|
foreach (var prop in point.Equipment.SelectMany(equipment => equipment.Properties))
|
|
{
|
|
SetParentsRecursively(prop);
|
|
}
|
|
}
|
|
|
|
private static void SetParentsRecursively(Property property)
|
|
{
|
|
foreach (var childProp in property.Properties)
|
|
{
|
|
childProp.Parent = property;
|
|
childProp.ParentPropertyId = property.Id;
|
|
SetParentsRecursively(childProp);
|
|
}
|
|
}
|
|
} |