AssignmentLookupDataModel.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.Collections;
  3. using System.Drawing;
  4. using InABox.Core;
  5. using Xamarin.Essentials;
  6. namespace comal.timesheets
  7. {
  8. public interface IAssignmentLookupDataModel
  9. {
  10. IEnumerable Items { get; }
  11. }
  12. public abstract class AssignmentLookupDataModel<TEntity, TShell> : ListDataModel<TEntity, TShell>, IAssignmentLookupDataModel
  13. where TEntity : Entity, IRemotable, IPersistent, new()
  14. where TShell : AssignmentLookupItem, new()
  15. {
  16. IEnumerable IAssignmentLookupDataModel.Items => Items;
  17. public void Clear()
  18. {
  19. foreach (var item in Items)
  20. item.Selected = false;
  21. }
  22. public void Select(Guid id)
  23. {
  24. foreach (var item in Items)
  25. item.Selected = item.Id == id;
  26. }
  27. }
  28. public abstract class AssignmentLookupItem : CoreDataModelItem
  29. {
  30. public abstract Guid Id { get; }
  31. public abstract String Number { get; }
  32. public abstract String Name { get; }
  33. public abstract String Description { get; }
  34. public bool Selected { get; set; }
  35. public Color Colour => Selected ? Color.LightPink : Color.White;
  36. }
  37. }