1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Comal.Classes;
- using InABox.Core;
- using InABox.Mobile;
- using System.Diagnostics.CodeAnalysis;
- namespace comal.timesheets
- {
- public class DigitalFormModel : ListModel<DigitalFormModel,DigitalFormShell,EmployeeDigitalForm>
- {
- public DigitalFormModel(IModelHost host, Func<Filter<EmployeeDigitalForm>> filter, bool transient = false) : base(host, filter, transient)
- {
- }
- public DigitalFormModel(IModelHost host, Func<Filter<EmployeeDigitalForm>> filter, [NotNull] string filename) : base(host, filter, filename)
- {
- }
- protected override void Initialize()
- {
- new DigitalFormLayoutShell();
- new DigitalFormDocumentShell();
- base.Initialize();
- Layouts = new CoreObservableCollection<DigitalFormLayoutShell>();
- _documents = new CoreObservableCollection<IDocumentShell>();
- }
- public CoreObservableCollection<DigitalFormLayoutShell> Layouts { get; private set; }
-
- private CoreObservableCollection<IDocumentShell> _documents;
-
- public IEnumerable<IDocumentShell> Documents => _documents;
- // public override Columns<(.+)> Columns => DigitalFormShell.Columns.Columns;
- public override void BeforeLoad(MultiQuery query)
- {
- base.BeforeLoad(query);
- query.Add(
- new Filter<DigitalFormLayout>(x => x.Form.ID).InQuery(Filter(), x => x.Form.ID)
- .And(x => x.Type).IsEqualTo(DFLayoutType.Mobile)
- .And(x => x.Active).IsEqualTo(true),
- DigitalFormLayoutShell.Columns.Columns
- );
- query.Add(
- new Filter<DigitalFormDocument>(x => x.EntityLink.ID).InQuery(Filter(), x => x.Form.ID),
- DigitalFormDocumentShell.Columns.Columns
- );
- }
- public override void AfterLoad(MultiQuery query)
- {
- base.AfterLoad(query);
-
- Layouts.ReplaceRange(
- query.Get<DigitalFormLayout>()
- .Rows
- .Select(x => new DigitalFormLayoutShell() { Row = x, Parent = this })
- .ToArray()
- );
-
- _documents.ReplaceRange(
- query.Get<DigitalFormDocument>()
- .Rows
- .Select(x => new DigitalFormDocumentShell() { Row = x, Parent = this })
- .ToArray()
- );
-
- }
- }
- }
|