using InnovEnergy.App.Backend.Model; using SQLite; namespace InnovEnergy.App.Backend.Database; public static partial class Db { public static IEnumerable Ancestors(this Installation installation) { var parentFolder = GetParent(installation); return parentFolder is null ? Enumerable.Empty() : Ancestors(parentFolder); } public static Folder? GetParent(this Installation installation) { return IsRoot(installation) ? null : GetFolderById(installation.ParentId); } public static Boolean IsRoot(this Installation i) { return i.ParentId == 0; // root has ParentId 0 by definition } public static Int64 CreateInstallation(this Installation installation) { return Create(installation); } public static Boolean UpdateInstallation(this Installation installation) { return Update(installation); } public static Boolean DeleteInstallation(this Installation installation) { User2Installation.Delete(i => i.InstallationId == installation.Id); return Delete(installation); } }