JobProductMapping.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using InABox.Core;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Linq.Expressions;
  6. using System.Text;
  7. namespace Comal.Classes
  8. {
  9. public class JobProductMapping : Entity, IRemotable, IPersistent, ILicense<ProjectManagementLicense>
  10. {
  11. [EntityRelationship(DeleteAction.Cascade)]
  12. [NullEditor]
  13. public JobLink Job { get; set; }
  14. [CodeEditor(Editable = Editable.Enabled, Visible = Visible.Default)]
  15. [EditorSequence(1)]
  16. public string Code { get; set; } = "";
  17. [MemoEditor(Visible = Visible.Default)]
  18. [EditorSequence(2)]
  19. public string Description { get; set; } = "";
  20. [EntityRelationship(DeleteAction.SetNull)]
  21. [EditorSequence(3)]
  22. public ProductLink Product { get; set; }
  23. private class JobDocumentSetLookup : LookupDefinitionGenerator<JobDocumentSet, JobProductMapping>
  24. {
  25. public override Filter<JobDocumentSet>? DefineFilter(JobProductMapping[] items)
  26. {
  27. var ids = items.Select(x => x.Job.ID).Distinct().ToArray();
  28. return ids.Any()
  29. ? new Filter<JobDocumentSet>(x => x.Job.ID).InList(ids)
  30. : new Filter<JobDocumentSet>().None();
  31. }
  32. public override Columns<JobProductMapping> DefineFilterColumns()
  33. {
  34. return Columns.None<JobProductMapping>().Add(x => x.ID)
  35. .Add(x=>x.Job.ID)
  36. .Add(x => x.Job.JobNumber)
  37. .Add(x => x.Job.Name);
  38. }
  39. }
  40. [LookupDefinition(typeof(JobDocumentSetLookup))]
  41. [EntityRelationship(DeleteAction.SetNull)]
  42. [EditorSequence(3)]
  43. public JobDocumentSetLink JobDocumentSet { get; set; }
  44. }
  45. }