JobShell.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Linq;
  3. using Comal.Classes;
  4. using InABox.Mobile;
  5. using Xamarin.Forms;
  6. namespace PRS.Mobile
  7. {
  8. public class JobShell : Shell<JobModel, Job>, ILookupShell
  9. {
  10. protected override void ConfigureColumns(ShellColumns<JobModel, Job> columns)
  11. {
  12. columns
  13. .Map(nameof(JobNumber), x => x.JobNumber)
  14. .Map(nameof(Name), x => x.Name)
  15. .Map(nameof(Status), x => x.JobStatus.Description)
  16. .Map(nameof(Active), x=>x.JobStatus.Active)
  17. .Map(nameof(_color), x => x.Color)
  18. .Map(nameof(_latitude), x => x.SiteAddress.Location.Latitude)
  19. .Map(nameof(_longitude), x => x.SiteAddress.Location.Longitude)
  20. .Map(nameof(Notes), x => x.Notes)
  21. .Map(nameof(OpenAssignments), x => x.OpenAssignments)
  22. .Map(nameof(Street), x=>x.SiteAddress.Street)
  23. .Map(nameof(City), x=>x.SiteAddress.City)
  24. .Map(nameof(PostCode), x=>x.SiteAddress.PostCode)
  25. .Map(nameof(ContactID), x=>x.Contact.ID)
  26. .Map(nameof(ContactName), x=>x.Contact.Name);
  27. }
  28. public string Name => Get<String>();
  29. public string JobNumber => Get<String>();
  30. public string[] Notes => Get<String[]>();
  31. public Guid ContactID => Get<Guid>();
  32. public String ContactName => Get<String>();
  33. public string Street => Get<String>();
  34. public string City => Get<String>();
  35. public string PostCode => Get<String>();
  36. private double _latitude => Get<double>();
  37. private double _longitude => Get<double>();
  38. public InABox.Core.Location Location => new InABox.Core.Location()
  39. {
  40. Latitude = _latitude,
  41. Longitude = _longitude
  42. };
  43. public int OpenAssignments => Get<int>();
  44. public String Status => Get<String>();
  45. public bool Active => Get<bool>();
  46. private String _color => Get<String>();
  47. public Color Color => Color.FromHex(_color);
  48. // Calculated Fields
  49. public string DisplayName => ID.Equals(Guid.Empty) ? "" : $"{JobNumber}: {Name}";
  50. // ILookupShell Wrapper
  51. public String LookupCode => JobNumber;
  52. public String LookupDescription => Name;
  53. public bool LookupSelected { get; set; }
  54. }
  55. }