TaskModel.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Windows.Media;
  3. using System.Windows.Media.Imaging;
  4. using Comal.Classes;
  5. using PropertyChanged;
  6. using Syncfusion.UI.Xaml.Kanban;
  7. namespace PRSDesktop;
  8. [DoNotNotify]
  9. public class TaskModel
  10. {
  11. public string Title { get; set; }
  12. public Guid ID { get; set; }
  13. public string Description { get; set; }
  14. public BitmapImage? Image { get; set; }
  15. public Color Color { get; set; }
  16. public bool Attachments { get; set; }
  17. public DateTime DueDate { get; set; }
  18. public DateTime CompletedDate { get; set; }
  19. public Guid EmployeeID { get; set; }
  20. public string AssignedTo { get; set; }
  21. public string Manager { get; set; }
  22. public Guid ManagerID { get; set; }
  23. public Guid JobID { get; set; }
  24. public string JobNumber { get; set; }
  25. public string JobName { get; set; }
  26. public bool Checked { get; set; }
  27. public KanbanStatus Status { get; set; }
  28. public Guid EmployeeCategory { get; set; }
  29. public KanbanType Type { get; set; }
  30. public int Number { get; set; }
  31. public bool Locked { get; set; }
  32. public TimeSpan EstimatedTime { get; set; }
  33. public bool ShowEmployeeImage { get; set; }
  34. /// <summary>
  35. /// A string representation of the Notes field of Kanban.
  36. /// </summary>
  37. public string Notes { get; set; }
  38. public bool IsAssignee => EmployeeID != Guid.Empty && EmployeeCategory == EmployeeID;
  39. public bool IsManager => ManagerID != Guid.Empty && EmployeeCategory == ManagerID;
  40. public bool Search(string[] searches)
  41. {
  42. foreach (var search in searches)
  43. {
  44. var bFound = JobNumber?.ToUpper().Contains(search.ToUpper()) == true
  45. || JobName?.ToUpper().Contains(search.ToUpper()) == true
  46. || Title?.ToUpper().Contains(search.ToUpper()) == true
  47. || Description?.ToUpper().Contains(search.ToUpper()) == true
  48. || Manager?.ToUpper().Contains(search.ToUpper()) == true
  49. || AssignedTo?.ToUpper().Contains(search.ToUpper()) == true
  50. || Number.ToString().Contains(search.ToUpper()) == true;
  51. if (!bFound)
  52. return false;
  53. }
  54. return true;
  55. }
  56. public bool JobSearch(Guid id)
  57. {
  58. return JobID == id;
  59. }
  60. public static System.Drawing.Color KanbanColor(DateTime duedate, DateTime completed)
  61. {
  62. var compareDate = completed == DateTime.MinValue ? DateTime.Today : completed.Date;
  63. var color = System.Drawing.Color.LightGreen;
  64. if (duedate < compareDate)
  65. color = System.Drawing.Color.Salmon;
  66. else if (duedate.Date == compareDate)
  67. color = System.Drawing.Color.Orange;
  68. else if (duedate < compareDate.AddDays(7))
  69. color = System.Drawing.Color.LightYellow;
  70. return color;
  71. }
  72. }