EmployeeMultiSelectionPage.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Linq;
  3. using InABox.Mobile;
  4. using Xamarin.Forms;
  5. namespace PRS.Mobile
  6. {
  7. public class EmployeeMultiSelectionPage : SelectionPage
  8. {
  9. public EmployeeMultiSelectionPage(Action<EmployeeShell[]> action)
  10. : base(
  11. (string)"SelectEmployee",
  12. (SelectionPageMode)SelectionPageMode.MultiSelect,
  13. (columns, filters) =>
  14. {
  15. columns
  16. .BeginUpdate()
  17. .Clear()
  18. .Add(new MobileGridTextColumn<EmployeeShell>()
  19. { Column = x => x.Code, Width = GridLength.Auto })
  20. .Add(new MobileGridTextColumn<EmployeeShell>()
  21. { Column = x => x.Name, Width = GridLength.Star })
  22. .EndUpdate();
  23. },
  24. (args) =>
  25. {
  26. App.Data.Employees.SelectFilter(args.Filter);
  27. var result = App.Data.Employees.Refresh(args.Force);
  28. args.LastUpdated = App.Data.Employees.LastUpdated;
  29. return result;
  30. },
  31. (items) => action?.Invoke(items.OfType<EmployeeShell>().ToArray())
  32. ) { }
  33. }
  34. }