ProductModel.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Linq;
  3. using System.Linq.Expressions;
  4. using Comal.Classes;
  5. using InABox.Core;
  6. using System.Diagnostics.CodeAnalysis;
  7. using Syncfusion.XForms.EffectsView;
  8. namespace comal.timesheets
  9. {
  10. public class ProductModel : ListModel<ProductModel, ProductShell, Product>
  11. {
  12. public ProductModel(IModelHost host, Func<Filter<Product>> filter, bool transient = false) : base(host, filter, transient)
  13. {
  14. }
  15. public ProductModel(IModelHost host, Func<Filter<Product>> filter, [NotNull] String filename) : base(host, filter, filename)
  16. {
  17. }
  18. protected override void Initialize()
  19. {
  20. base.Initialize();
  21. DimensionUnits = new ProductDimensionUnitShell[] { };
  22. }
  23. public ProductDimensionUnitShell[] DimensionUnits { get; private set; }
  24. // public override Columns<(.+)> Columns => ProductShell.Columns.Columns;
  25. protected override Expression<Func<Product, object>> ImageColumn => x => x.Image.ID;
  26. public override void BeforeLoad(MultiQuery query)
  27. {
  28. base.BeforeLoad(query);
  29. query.Add(
  30. null,
  31. ProductDimensionUnitShell.Columns.Columns
  32. );
  33. }
  34. public override void AfterLoad(MultiQuery query)
  35. {
  36. base.AfterLoad(query);
  37. DimensionUnits = query.Get<ProductDimensionUnit>()
  38. .Rows
  39. .Select(x => new ProductDimensionUnitShell() { Row = x, Parent = this })
  40. .ToArray();
  41. }
  42. }
  43. }