JobDocumentFolderModel.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Linq;
  3. using Comal.Classes;
  4. using InABox.Core;
  5. using InABox.Mobile;
  6. namespace PRS.Mobile
  7. {
  8. public class JobDocumentFolderModel : CoreRepository<JobDocumentFolderModel, JobDocumentFolderShell, JobDocumentSetFolder>
  9. {
  10. public JobDocumentFolderModel(IModelHost host, Func<Filter<JobDocumentSetFolder>> filter): base(host, filter)
  11. {
  12. }
  13. protected override void Initialize()
  14. {
  15. base.Initialize();
  16. DocumentFolders = new CoreTreeNodes<Guid>(Guid.Empty);
  17. }
  18. public CoreTreeNodes<Guid> DocumentFolders { get; private set; }
  19. protected override void AfterLoad(MultiQuery query)
  20. {
  21. base.AfterLoad(query);
  22. var table = query.Get<JobDocumentSetFolder>();
  23. foreach (var row in table.Rows.Where(r =>
  24. r.Get<JobDocumentSetFolder, Guid>(c => c.Parent.ID) == Guid.Empty))
  25. row.Set<JobDocumentSetFolder, Guid>(c => c.Parent.ID,CoreUtils.FullGuid);
  26. var root = table.NewRow();
  27. root.Set<JobDocumentSetFolder, Guid>(c => c.ID,CoreUtils.FullGuid);
  28. root.Set<JobDocumentSetFolder, Guid>(c => c.Parent.ID,Guid.Empty);
  29. root.Set<JobDocumentSetFolder, String>(c => c.Name,"All Folders");
  30. table.Rows.Add(root);
  31. DocumentFolders.Load<JobDocumentSetFolder>(
  32. table,
  33. x=>x.ID,
  34. x=>x.Parent.ID
  35. //, x=>x.Name
  36. );
  37. //var roots = DocumentFolders.GetChildren(Guid.Empty);
  38. //foreach (var root in roots)
  39. // root.Parent = CoreUtils.FullGuid;
  40. //DocumentFolders.Add(CoreUtils.FullGuid, Guid.Empty).Description = "All Folders";
  41. }
  42. }
  43. }