TimeSheetShell.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using Comal.Classes;
  3. using InABox.Core;
  4. using InABox.Mobile;
  5. using Xamarin.Forms;
  6. using Xamarin.Forms.Xaml;
  7. namespace PRS.Mobile
  8. {
  9. public class TimeSheetShell : Shell<TimeSheetModel,TimeSheet>
  10. {
  11. public static Filter<TimeSheet> UnprocessedTimeSheets => new Filter<TimeSheet>(x => x.EmployeeLink.ID)
  12. .IsEqualTo(App.Data.Me.ID)
  13. .And(x => x.Processed).IsEqualTo(DateTime.MinValue);
  14. protected override void ConfigureColumns(ShellColumns<TimeSheetModel, TimeSheet> columns)
  15. {
  16. columns
  17. .Map(nameof(Date), x => x.Date)
  18. .Map(nameof(_actualstart), x => x.Start)
  19. .Map(nameof(_actualfinish), x => x.Finish)
  20. .Map(nameof(_approvedstart), x => x.ApprovedStart)
  21. .Map(nameof(_approvedfinish), x => x.ApprovedFinish)
  22. .Map(nameof(_approved), x => x.Approved)
  23. .Map(nameof(StartLongitude), x => x.StartLocation.Longitude)
  24. .Map(nameof(StartLatitude), x => x.StartLocation.Latitude)
  25. .Map(nameof(StartAddress), x => x.StartLocation.Address)
  26. .Map(nameof(StartTimeStamp), x => x.StartLocation.Timestamp)
  27. .Map(nameof(FinishLongitude), x => x.FinishLocation.Longitude)
  28. .Map(nameof(FinishLatitude), x => x.FinishLocation.Latitude)
  29. .Map(nameof(FinishAddress), x => x.FinishLocation.Address)
  30. .Map(nameof(FinishTimeStamp), x => x.FinishLocation.Timestamp)
  31. .Map(nameof(JobID), x => x.JobLink.ID)
  32. .Map(nameof(JobNumber), x => x.JobLink.JobNumber)
  33. .Map(nameof(JobName), x => x.JobLink.Name)
  34. .Map(nameof(Notes), x => x.Notes);
  35. }
  36. public DateTime Date
  37. {
  38. get => Get<DateTime>();
  39. set => Set(value);
  40. }
  41. private TimeSpan _actualstart
  42. {
  43. get => Get<TimeSpan>();
  44. set => Set(value);
  45. }
  46. private TimeSpan _actualfinish
  47. {
  48. get => Get<TimeSpan>();
  49. set => Set(value);
  50. }
  51. private TimeSpan _approvedstart
  52. {
  53. get => Get<TimeSpan>();
  54. set => Set(value);
  55. }
  56. private TimeSpan _approvedfinish
  57. {
  58. get => Get<TimeSpan>();
  59. set => Set(value);
  60. }
  61. private DateTime _approved
  62. {
  63. get => Get<DateTime>();
  64. set => Set(value);
  65. }
  66. public TimeSpan Start => _approved.IsEmpty()
  67. ? _actualstart
  68. : _approvedstart;
  69. public TimeSpan Finish => _approved.IsEmpty()
  70. ? _actualfinish
  71. : _approvedfinish;
  72. public ImageSource? Approved => _approved.IsEmpty()
  73. ? null
  74. : ImageSource.FromFile("tick");
  75. public double StartLongitude
  76. {
  77. get => Get<double>();
  78. set => Set(value);
  79. }
  80. public double StartLatitude
  81. {
  82. get => Get<double>();
  83. set => Set(value);
  84. }
  85. public string StartAddress
  86. {
  87. get => Get<string>();
  88. set => Set(value);
  89. }
  90. public DateTime StartTimeStamp
  91. {
  92. get => Get<DateTime>();
  93. set => Set(value);
  94. }
  95. public double FinishLongitude
  96. {
  97. get => Get<double>();
  98. set => Set(value);
  99. }
  100. public double FinishLatitude
  101. {
  102. get => Get<double>();
  103. set => Set(value);
  104. }
  105. public string FinishAddress
  106. {
  107. get => Get<string>();
  108. set => Set(value);
  109. }
  110. public DateTime FinishTimeStamp
  111. {
  112. get => Get<DateTime>();
  113. set => Set(value);
  114. }
  115. public Guid JobID
  116. {
  117. get => Get<Guid>();
  118. set => Set(value);
  119. }
  120. public string JobNumber
  121. {
  122. get => Get<string>();
  123. set => Set(value);
  124. }
  125. public string JobName
  126. {
  127. get => Get<string>();
  128. set => Set(value);
  129. }
  130. public string Notes
  131. {
  132. get => Get<string>();
  133. set => Set(value);
  134. }
  135. }
  136. }