| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System.Linq;
- using InABox.Core;
- namespace Comal.Classes
- {
- public class JobScopeLookups : EntityLookup<JobScope>, ILookupDefinition<JobScope, InvoiceLine>, ILookupDefinition<JobScope, Job>
- , ILookupDefinition<JobScope, Assignment>
- {
-
- #region Invoice Lines
-
- public Filter<JobScope> DefineFilter(InvoiceLine[] items)
- {
- if (items == null)
- return new Filter<JobScope>(x => x.ID).IsEqualTo(CoreUtils.FullGuid);
- var jobid = CoreUtils.FullGuid;
- foreach (var item in items)
- {
- if (jobid == CoreUtils.FullGuid)
- jobid = item.InvoiceLink.JobLink.ID;
- if (item.InvoiceLink.JobLink.ID != jobid)
- return new Filter<JobScope>(x => x.ID).IsEqualTo(CoreUtils.FullGuid);
- }
- return new Filter<JobScope>(x => x.Job.ID).IsEqualTo(jobid).And(x => x.Status.Approved).IsEqualTo(true);
- }
-
- Columns<InvoiceLine> ILookupDefinition<JobScope, InvoiceLine>.DefineFilterColumns()
- => new Columns<InvoiceLine>(x => x.InvoiceLink.JobLink.ID);
- #endregion
-
- #region Assignments
- public Filter<JobScope> DefineFilter(Assignment[] items)
- {
- var item = items?.Length == 1 ? items[0] : null;
- if (item != null)
- return new Filter<JobScope>(x => x.Job.ID).IsEqualTo(item.JobLink.ID).And(x => x.Status.Approved).IsEqualTo(true);
- return new Filter<JobScope>(x => x.ID).None();
- }
-
- Columns<Assignment> ILookupDefinition<JobScope, Assignment>.DefineFilterColumns()
- => new Columns<Assignment>(x=>x.JobLink.ID);
- #endregion
-
- #region Jobs (Default Scope)
-
- public Filter<JobScope> DefineFilter(Job[] items)
- {
- var item = items?.Length == 1 ? items[0] : null;
- if (item != null)
- return new Filter<JobScope>(x => x.Job.ID).IsEqualTo(item.ID).And(x => x.Status.Approved).IsEqualTo(true);
- return new Filter<JobScope>(x => x.ID).None();
- }
-
- Columns<Job> ILookupDefinition<JobScope, Job>.DefineFilterColumns()
- => new Columns<Job>(x=>x.ID);
-
-
- #endregion
-
- public override Columns<JobScope> DefineColumns()
- {
- return new Columns<JobScope>().Default();
- }
- public override Filter<JobScope> DefineFilter()
- {
- return new Filter<JobScope>(x => x.ID).IsEqualTo(CoreUtils.FullGuid);
- }
- public override SortOrder<JobScope> DefineSortOrder()
- {
- return new SortOrder<JobScope>(x => x.Number);
- }
- }
- }
|