| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using System.Linq;
- using System.Linq.Expressions;
- using Comal.Classes;
- using InABox.Core;
- using InABox.Mobile;
- using System.Diagnostics.CodeAnalysis;
- namespace comal.timesheets
- {
- public class EquipmentDetailModel : DetailModel<EquipmentDetailModel,EquipmentDetailShell,Equipment>
- {
- public EquipmentDetailModel(IModelHost host, Func<Filter<Equipment>> filter, bool transient = false) : base(host, filter, transient)
- {
- }
- public EquipmentDetailModel(IModelHost host, Func<Filter<Equipment>> filter, [NotNull] string filename) : base(host, filter, filename)
- {
- }
-
- protected override void Initialize()
- {
- base.Initialize();
- Documents = new CoreObservableCollection<IDocumentShell>();
- Kanbans = new CoreObservableCollection<EquipmentKanbanShell>();
- }
-
- // public override Columns<(.+)> Columns => EquipmentDetailShell.Columns.Columns;
- public CoreObservableCollection<IDocumentShell> Documents { get; private set; }
- public CoreObservableCollection<EquipmentKanbanShell> Kanbans { get; private set; }
- protected override Expression<Func<Equipment, object>> ImageColumn => x => x.SpecificationSheet.ID;
-
- public override void BeforeLoad(MultiQuery query)
- {
- base.BeforeLoad(query);
-
- query.Add(
- new Filter<EquipmentDocument>(x => x.EntityLink.ID).InQuery(Filter(),x=>x.ID),
- EquipmentDocumentShell.Columns.Columns
- );
-
- query.Add(
- new Filter<Kanban>(x => x.Equipment.ID).InQuery(Filter(),x=>x.ID),
- EquipmentKanbanShell.Columns.Columns
- );
- }
- public override void AfterLoad(MultiQuery query)
- {
- base.AfterLoad(query);
-
- Documents.ReplaceRange(
- query.Get<EquipmentDocument>()
- .Rows
- .Select(x => new EquipmentDocumentShell() { Row = x, Parent = this })
- .ToArray()
- );
-
- Kanbans.ReplaceRange(
- query.Get<Kanban>()
- .Rows
- .Select(x => new EquipmentKanbanShell() { Row = x, Parent = this })
- .ToArray()
- );
- }
- }
- }
|