| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 | using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using Comal.Classes;using InABox.Core;using System.Diagnostics.CodeAnalysis;using InABox.Mobile;namespace comal.timesheets{    public class DeliveryItemDetailModel : DetailModel<DeliveryItemDetailModel, DeliveryItemDetailShell, DeliveryItem>    {        public DeliveryItemDetailModel(IModelHost host, Func<Filter<DeliveryItem>> filter, bool transient = false) : base(host, filter, transient)        {            new DeliveryItemDetailDeliveryDocumentShell();            new DeliveryItemDetailSetoutDocumentShell();        }        public DeliveryItemDetailModel(IModelHost host, Func<Filter<DeliveryItem>> filter, [NotNull] string filename) : base(host, filter, filename)        {            new DeliveryItemDetailDeliveryDocumentShell();            new DeliveryItemDetailSetoutDocumentShell();        }        protected override void Initialize()        {            base.Initialize();            DeliveryDocuments = new CoreObservableCollection<DeliveryItemDetailDeliveryDocumentShell>();            SetoutDocuments = new CoreObservableCollection<DeliveryItemDetailSetoutDocumentShell>();        }                public CoreObservableCollection<DeliveryItemDetailDeliveryDocumentShell> DeliveryDocuments { get; private set; }        public CoreObservableCollection<DeliveryItemDetailSetoutDocumentShell> SetoutDocuments { get; private set; }        public override void BeforeLoad(MultiQuery query)        {            base.BeforeLoad(query);            query.Add<DeliveryDocument>(                new Filter<DeliveryDocument>(x => x.EntityLink.ID).InQuery<DeliveryItem>(Filter(), x => x.Delivery.ID),                DeliveryItemDetailDeliveryDocumentShell.Columns.Columns);                        query.Add<SetoutDocument>(                new Filter<SetoutDocument>(x => x.EntityLink.ID).InQuery<DeliveryItem>(Filter(), x => x.SetoutLink.ID),                DeliveryItemDetailSetoutDocumentShell.Columns.Columns);        }        public override void AfterLoad(MultiQuery query)        {            base.AfterLoad(query);            var deldocs = query.Get<DeliveryDocument>()                .Rows                .Select(x => new DeliveryItemDetailDeliveryDocumentShell() { Row = x, Parent = this });            DeliveryDocuments.ReplaceRange(deldocs);            var mfgdocs = query.Get<SetoutDocument>()                .Rows                .Select(x=> new DeliveryItemDetailSetoutDocumentShell() { Row = x, Parent = this})                .ToArray();            SetoutDocuments.ReplaceRange(mfgdocs);        }    }}
 |