StockAreaLoookups.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Linq;
  2. using InABox.Core;
  3. namespace Comal.Classes
  4. {
  5. public class StockAreaLoookups : EntityLookup<StockArea>, ILookupDefinition<StockArea, StockLocation>
  6. {
  7. public Filter<StockArea> DefineFilter(StockLocation[] items)
  8. {
  9. var ids = items.Select(x => x.Warehouse.ID).Distinct().ToArray();
  10. if (ids.Length == 1)
  11. return new Filter<StockArea>(x => x.Warehouse.ID).IsEqualTo(ids[0]).And(x => x.Active).IsEqualTo(true);
  12. return new Filter<StockArea>(x => x.ID).IsEqualTo(CoreUtils.FullGuid);
  13. }
  14. public override Columns<StockArea> DefineColumns()
  15. {
  16. return new Columns<StockArea>(
  17. x => x.ID,
  18. x => x.Code,
  19. x => x.Description
  20. );
  21. }
  22. public override Filter<StockArea> DefineFilter()
  23. {
  24. return new Filter<StockArea>(x => x.Active).IsEqualTo(true);
  25. }
  26. public override SortOrder<StockArea> DefineSortOrder()
  27. {
  28. return new SortOrder<StockArea>(x => x.Code);
  29. }
  30. }
  31. }