using System; using System.Linq; using Comal.Classes; using InABox.Core; using InABox.Mobile; namespace PRS.Mobile { public class JobDocumentFolderModel : CoreRepository { public JobDocumentFolderModel(IModelHost host, Func> filter): base(host, filter) { } protected override void Initialize() { base.Initialize(); DocumentFolders = new CoreTreeNodes(Guid.Empty); } public CoreTreeNodes DocumentFolders { get; private set; } protected override void AfterLoad(MultiQuery query) { base.AfterLoad(query); var table = query.Get(); foreach (var row in table.Rows.Where(r => r.Get(c => c.Parent.ID) == Guid.Empty)) row.Set(c => c.Parent.ID,CoreUtils.FullGuid); var root = table.NewRow(); root.Set(c => c.ID,CoreUtils.FullGuid); root.Set(c => c.Parent.ID,Guid.Empty); root.Set(c => c.Name,"All Folders"); table.Rows.Add(root); DocumentFolders.Load( table, x=>x.ID, x=>x.Parent.ID //, x=>x.Name ); //var roots = DocumentFolders.GetChildren(Guid.Empty); //foreach (var root in roots) // root.Parent = CoreUtils.FullGuid; //DocumentFolders.Add(CoreUtils.FullGuid, Guid.Empty).Description = "All Folders"; } } }