EquipmentModel.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Linq;
  3. using System.Linq.Expressions;
  4. using Comal.Classes;
  5. using InABox.Core;
  6. using System.Diagnostics.CodeAnalysis;
  7. namespace comal.timesheets
  8. {
  9. public class EquipmentModel : ListModel<EquipmentModel, EquipmentShell, Equipment>
  10. {
  11. public EquipmentModel(IModelHost host, Func<Filter<Equipment>> filter, bool transient = false) : base(host, filter, transient)
  12. {
  13. //new EquipmentDocumentShell();
  14. //new EquipmentKanbanShell();
  15. //Reset();
  16. }
  17. public EquipmentModel(IModelHost host, Func<Filter<Equipment>> filter, [NotNull] String filename) : base(host, filter, filename)
  18. {
  19. //new EquipmentDocumentShell();
  20. //new EquipmentKanbanShell();
  21. //Reset();
  22. }
  23. // private void Reset()
  24. // {
  25. // Kanbans = new EquipmentKanbanShell[] { };
  26. // Documents = new EquipmentDocumentShell[] { };
  27. // }
  28. // public override Columns<Equipment> Columns => EquipmentShell.Columns.
  29. protected override Expression<Func<Equipment, object>> ImageColumn => x => x.GroupLink.Thumbnail.ID;
  30. //public EquipmentKanbanShell[] Kanbans { get; private set; }
  31. //public EquipmentDocumentShell[] Documents { get; private set; }
  32. public String[] GroupNames => Items.Select(x => x.GroupName).Distinct().OrderBy(x => x).Prepend("All").ToArray();
  33. // public override void BeforeLoad(MultiQuery query)
  34. // {
  35. // base.BeforeLoad(query);
  36. //
  37. // query.Add(
  38. // new Filter<Kanban>(x => x.Equipment.ID).InQuery(Filter(), x => x.ID),
  39. // EquipmentKanbanShell.Columns.Columns
  40. // );
  41. //
  42. // query.Add(
  43. // new Filter<EquipmentDocument>(x => x.EntityLink.ID).InQuery(Filter(), x => x.ID),
  44. // EquipmentDocumentShell.Columns.Columns
  45. // );
  46. // }
  47. // public override void AfterLoad(MultiQuery query)
  48. // {
  49. // base.AfterLoad(query);
  50. // Kanbans = query.Get<Kanban>()
  51. // .Rows
  52. // .Select(x => new EquipmentKanbanShell() { Row = x, Parent = this })
  53. // .ToArray();
  54. // Documents = query.Get<EquipmentDocument>()
  55. // .Rows
  56. // .Select(x => new EquipmentDocumentShell() { Row = x, Parent = this })
  57. // .ToArray();
  58. // }
  59. // protected override void DoUnload()
  60. // {
  61. // base.DoUnload();
  62. // Reset();
  63. // }
  64. }
  65. }