DigitalFormModel.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Comal.Classes;
  5. using InABox.Core;
  6. using InABox.Mobile;
  7. using System.Diagnostics.CodeAnalysis;
  8. namespace PRS.Mobile
  9. {
  10. public class DigitalFormModel : CoreRepository<DigitalFormModel,DigitalFormShell,EmployeeDigitalForm>
  11. {
  12. public DigitalFormModel(IModelHost host, Func<Filter<EmployeeDigitalForm>>? filter = null, Func<string>? cachefilename = null) : base(host, filter, cachefilename)
  13. {
  14. }
  15. protected override void Initialize()
  16. {
  17. base.Initialize();
  18. Layouts = new CoreObservableCollection<DigitalFormLayoutShell>();
  19. //_documents = new CoreObservableCollection<IDocumentShell>();
  20. }
  21. public CoreObservableCollection<DigitalFormLayoutShell> Layouts { get; private set; }
  22. //private CoreObservableCollection<IDocumentShell> _documents;
  23. //public IEnumerable<IDocumentShell> Documents => _documents;
  24. // public override Columns<(.+)> Columns => DigitalFormShell.Columns.Columns;
  25. protected override void BeforeLoad(MultiQuery query)
  26. {
  27. base.BeforeLoad(query);
  28. query.Add(
  29. new Filter<DigitalFormLayout>(x => x.Form.ID).InQuery(EffectiveFilter(), x => x.Form.ID)
  30. .And(x => x.Type).IsEqualTo(DFLayoutType.Mobile)
  31. .And(x => x.Active).IsEqualTo(true),
  32. GetColumns<DigitalFormLayoutShell,DigitalFormLayout>()
  33. );
  34. //query.Add(
  35. // new Filter<DigitalFormDocument>(x => x.EntityLink.ID).InQuery(EffectiveFilter(), x => x.Form.ID),
  36. // GetColumns<DigitalFormDocumentShell,DigitalFormDocument>()
  37. //);
  38. }
  39. protected override void AfterLoad(MultiQuery query)
  40. {
  41. base.AfterLoad(query);
  42. Layouts.ReplaceRange(
  43. query.Get<DigitalFormLayout>()
  44. .Rows
  45. .Select(x => new DigitalFormLayoutShell() { Row = x, Parent = this })
  46. .ToArray()
  47. );
  48. //_documents.ReplaceRange(
  49. // query.Get<DigitalFormDocument>()
  50. // .Rows
  51. // .Select(x => new DigitalFormDocumentShell() { Row = x, Parent = this })
  52. // .ToArray()
  53. //);
  54. }
  55. }
  56. }