TaskModel.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 string Category { get; set; }
  28. public KanbanType Type { get; set; }
  29. public int Number { get; set; }
  30. public bool Locked { get; set; }
  31. public TimeSpan EstimatedTime { get; set; }
  32. /// <summary>
  33. /// A string representation of the Notes field of Kanban.
  34. /// </summary>
  35. public string Notes { get; set; }
  36. public bool Search(string[] searches)
  37. {
  38. foreach (var search in searches)
  39. {
  40. var bFound = JobNumber?.ToUpper().Contains(search.ToUpper()) == true
  41. || JobName?.ToUpper().Contains(search.ToUpper()) == true
  42. || Title?.ToUpper().Contains(search.ToUpper()) == true
  43. || Description?.ToUpper().Contains(search.ToUpper()) == true
  44. || Manager?.ToUpper().Contains(search.ToUpper()) == true
  45. || AssignedTo?.ToUpper().Contains(search.ToUpper()) == true
  46. || Number.ToString().Contains(search.ToUpper()) == true;
  47. if (!bFound)
  48. return false;
  49. }
  50. return true;
  51. }
  52. public bool JobSearch(Guid id)
  53. {
  54. return JobID == id;
  55. }
  56. public static System.Drawing.Color KanbanColor(DateTime duedate, DateTime completed)
  57. {
  58. var compareDate = completed == DateTime.MinValue ? DateTime.Today : completed.Date;
  59. var color = System.Drawing.Color.LightGreen;
  60. if (duedate < compareDate)
  61. color = System.Drawing.Color.Salmon;
  62. else if (duedate.Date == compareDate)
  63. color = System.Drawing.Color.Orange;
  64. else if (duedate < compareDate.AddDays(7))
  65. color = System.Drawing.Color.LightYellow;
  66. return color;
  67. }
  68. }