ProductStyle.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using InABox.Core;
  2. using System;
  3. using System.Linq;
  4. namespace Comal.Classes
  5. {
  6. [UserTracking(typeof(Product))]
  7. public class ProductStyle : Entity, IRemotable, IPersistent, IProductStyle, ILicense<ProductManagementLicense>, IMergeable, IIssues, IProblems<ManagedProblem>
  8. {
  9. [EditorSequence(1)]
  10. [UniqueCodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
  11. public string Code { get; set; } = "";
  12. [EditorSequence(2)]
  13. [TextBoxEditor]
  14. public string Description { get; set; } = "";
  15. [EditorSequence(3)]
  16. [DataModelTableName("Image")]
  17. public ImageDocumentLink Image { get; set; }
  18. private class TreatmentTypeLookup : LookupDefinitionGenerator<TreatmentType, Product>
  19. {
  20. public override Filter<TreatmentType>? DefineFilter(Product[] items)
  21. {
  22. return new Filter<TreatmentType>(x => x.Active).IsEqualTo(true);
  23. }
  24. }
  25. [LookupDefinition(typeof(TreatmentTypeLookup))]
  26. [EditorSequence(4)]
  27. public TreatmentTypeLink TreatmentType { get; set; }
  28. [EditorSequence(5)]
  29. public ProductStyleGroupLink Group { get; set; }
  30. [NullEditor]
  31. [Obsolete("Replaced with Problem", true)]
  32. public string Issues { get; set; }
  33. [EditorSequence("Issues", 1)]
  34. public ManagedProblem Problem { get; set; }
  35. private class TreatmentProductLookup : LookupDefinitionGenerator<Product, ProductStyle>
  36. {
  37. public override Filter<Product>? DefineFilter(ProductStyle[] items)
  38. {
  39. var treatmentID = items.Select(x => x.TreatmentType.ID).SingleOrDefault();
  40. if(treatmentID == Guid.Empty)
  41. {
  42. return Filter.None<Product>();
  43. }
  44. else
  45. {
  46. return new Filter<Product>(x => x.TreatmentType.ID).IsEqualTo(treatmentID);
  47. }
  48. }
  49. public override Columns<ProductStyle> DefineFilterColumns()
  50. {
  51. return Columns.None<ProductStyle>().Add(x => x.TreatmentType.ID);
  52. }
  53. }
  54. [LookupDefinition(typeof(TreatmentProductLookup))]
  55. public ProductLink ManufacturingTreatmentProduct { get; set; }
  56. [LookupDefinition(typeof(TreatmentProductLookup))]
  57. public ProductLink StockTreatmentProduct { get; set; }
  58. public override string ToString() => $"{Code}: {Description}";
  59. }
  60. }