JobStageLookups.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Linq;
  3. using InABox.Core;
  4. namespace Comal.Classes
  5. {
  6. public class JobStageLookups : EntityLookup<JobStage>, ILookupDefinition<JobStage, Job>, ILookupDefinition<JobStage, Setout>,
  7. ILookupDefinition<JobStage, ManufacturingPacket>, ILookupDefinition<JobStage, JobStage>
  8. {
  9. public Filter<JobStage> DefineFilter(Job[] items)
  10. {
  11. if (items.Length == 1)
  12. return new Filter<JobStage>(x => x.Job.ID).IsEqualTo(items.First().ID).And(x => x.IsHeader).IsEqualTo(false);
  13. return new Filter<JobStage>(x => x.ID).IsEqualTo(Guid.Empty);
  14. }
  15. Columns<Job> ILookupDefinition<JobStage, Job>.DefineFilterColumns()
  16. => new Columns<Job>(x => x.ID);
  17. public Filter<JobStage> DefineFilter(JobStage[] items)
  18. {
  19. if (items.Length == 1)
  20. return new Filter<JobStage>(x => x.Job.ID).IsEqualTo(items.First().Job.ID).And(x => x.IsHeader).IsEqualTo(false);
  21. return new Filter<JobStage>(x => x.ID).IsEqualTo(Guid.Empty);
  22. }
  23. Columns<JobStage> ILookupDefinition<JobStage, JobStage>.DefineFilterColumns()
  24. => new Columns<JobStage>(x => x.Job.ID);
  25. public Filter<JobStage> DefineFilter(ManufacturingPacket[] items)
  26. {
  27. if (items.Length == 1)
  28. return new Filter<JobStage>(x => x.Job.ID).IsEqualTo(items.First().SetoutLink.JobLink.ID).And(x => x.IsHeader).IsEqualTo(false);
  29. return new Filter<JobStage>(x => x.ID).IsEqualTo(Guid.Empty);
  30. }
  31. Columns<ManufacturingPacket> ILookupDefinition<JobStage, ManufacturingPacket>.DefineFilterColumns()
  32. => new Columns<ManufacturingPacket>(x => x.SetoutLink.JobLink.ID);
  33. public Filter<JobStage> DefineFilter(Setout[] items)
  34. {
  35. if (items.Length == 1)
  36. return new Filter<JobStage>(x => x.Job.ID).IsEqualTo(items.First().JobLink.ID).And(x => x.IsHeader).IsEqualTo(false);
  37. return new Filter<JobStage>(x => x.ID).IsEqualTo(Guid.Empty);
  38. }
  39. Columns<Setout> ILookupDefinition<JobStage, Setout>.DefineFilterColumns()
  40. => new Columns<Setout>(x => x.JobLink.ID);
  41. public override Filter<JobStage> DefineFilter()
  42. {
  43. return new Filter<JobStage>(x => x.ID).IsEqualTo(Guid.Empty);
  44. }
  45. public override Columns<JobStage> DefineColumns()
  46. {
  47. return new Columns<JobStage>(
  48. x => x.ID,
  49. x => x.Name
  50. );
  51. }
  52. public override SortOrder<JobStage> DefineSortOrder()
  53. {
  54. return new SortOrder<JobStage>(x => x.Sequence);
  55. }
  56. }
  57. }