Implemented method to calculate a section's path

This commit is contained in:
Thorsten Sommer 2022-07-12 21:04:33 +02:00
parent 10952769aa
commit 5428cb9489
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -137,4 +137,17 @@ public static class SectionProcessor
}
public static Section GetSection(DataContext db, string sectionKey) => db.Sections.First(n => n.DataKey == sectionKey);
public static string GetSectionPath(DataContext db, string sectionKey)
{
var section = db.Sections.First(n => n.DataKey == sectionKey);
var path = section.Name;
while (section.Parent != null)
{
section = section.Parent;
path = $"{section.Name}/{path}";
}
return $"Section's path: {path}";
}
}