JobDocumentSetLink.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Linq;
  3. using InABox.Core;
  4. namespace Comal.Classes
  5. {
  6. public class JobDocumentSetLink : EntityLink<JobDocumentSet>, IJobDocumentSet
  7. {
  8. [LookupEditor(typeof(JobDocumentSet))]
  9. public override Guid ID { get; set; }
  10. [NullEditor]
  11. public JobLink Job { get; set; }
  12. [NullEditor]
  13. public JobDocumentSetFolderLink Folder { get; set; }
  14. [CodeEditor(Editable = Editable.Hidden)]
  15. [EditorSequence(1)]
  16. public string Code { get; set; }
  17. [TextBoxEditor(Editable = Editable.Hidden)]
  18. [EditorSequence(2)]
  19. public string Description { get; set; }
  20. public JobDocumentSetDisciplineLink Discipline { get; set; }
  21. public JobDocumentSetTypeLink Type { get; set; }
  22. public JobDocumentSetCategoryLink Category { get; set; }
  23. public JobITPLink Area { get; set; }
  24. public LightJobDocumentSetMileStoneLink CurrentMileStone { get; set; }
  25. }
  26. public class JobDocumentSetLookups : EntityLookup<JobDocumentSet>,
  27. ILookupDefinition<JobDocumentSet,JobProductMapping>,
  28. ILookupDefinition<JobDocumentSet,JobStyle>
  29. {
  30. public override Filter<JobDocumentSet>? DefineFilter()
  31. {
  32. return null;
  33. }
  34. public override SortOrder<JobDocumentSet> DefineSortOrder()
  35. {
  36. return new SortOrder<JobDocumentSet>(x=>x.Code);
  37. }
  38. public override Columns<JobDocumentSet> DefineColumns()
  39. {
  40. return new Columns<JobDocumentSet>(x => x.ID)
  41. .Add(x => x.Code)
  42. .Add(x => x.Description);
  43. }
  44. public Filter<JobDocumentSet>? DefineFilter(JobProductMapping[] items)
  45. {
  46. var ids = items.Select(x => x.Job.ID).Distinct().ToArray();
  47. return ids.Any()
  48. ? new Filter<JobDocumentSet>(x => x.Job.ID).InList(ids)
  49. : new Filter<JobDocumentSet>().None();
  50. }
  51. Columns<JobProductMapping> ILookupDefinition<JobDocumentSet, JobProductMapping>.DefineFilterColumns()
  52. {
  53. return new Columns<JobProductMapping>(x => x.ID)
  54. .Add(x=>x.Job.ID)
  55. .Add(x => x.Job.JobNumber)
  56. .Add(x => x.Job.Name);
  57. }
  58. public Filter<JobDocumentSet>? DefineFilter(JobStyle[] items)
  59. {
  60. var ids = items.Select(x => x.Job.ID).Distinct().ToArray();
  61. return ids.Any()
  62. ? new Filter<JobDocumentSet>(x => x.Job.ID).InList(ids)
  63. : new Filter<JobDocumentSet>().None();
  64. }
  65. Columns<JobStyle> ILookupDefinition<JobDocumentSet, JobStyle>.DefineFilterColumns()
  66. {
  67. return new Columns<JobStyle>(x => x.ID)
  68. .Add(x=>x.Job.ID)
  69. .Add(x => x.Job.JobNumber)
  70. .Add(x => x.Job.Name);
  71. }
  72. }
  73. }