Advertisement
MeliDragon

Untitled

Apr 15th, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. public class ListTasksWithAssigneeCommand : BaseCommand
  2. {
  3. public const int ExpectedNumberOfArguments = 1;
  4.  
  5. public ListTasksWithAssigneeCommand(IList<string> commandParameters, IRepository repository)
  6. : base(commandParameters, repository)
  7. {
  8. }
  9.  
  10. public override string Execute()
  11. {
  12. string comand = CommandParameters[0];
  13. StringBuilder taskDisplay = new StringBuilder();
  14. var tasksTypeBug = Repository.Tasks.OfType<Bug>().ToList();
  15. var tasksTypeStory = Repository.Tasks.OfType<Story>().ToList();
  16. switch (comand)
  17. {
  18. case "Active":
  19. tasksTypeBug = tasksTypeBug.
  20. Where(bug => bug.Status == BugStatusType.Active && bug.Assignee.TeamAssignedTo != null).
  21. OrderBy(bug => bug.Title).
  22. ToList();
  23.  
  24. foreach(var bug in tasksTypeBug)
  25. {
  26. taskDisplay.Append(bug);
  27. }
  28. break;
  29. case "Fixed":
  30. tasksTypeBug = tasksTypeBug.
  31. Where(bug => bug.Status == BugStatusType.Fixed && bug.Assignee.TeamAssignedTo != null).
  32. OrderBy(bug => bug.Title).
  33. ToList();
  34.  
  35. foreach (var bug in tasksTypeBug)
  36. {
  37. taskDisplay.Append(bug);
  38. }
  39. break;
  40. case "NotDone":
  41. tasksTypeStory = tasksTypeStory.
  42. Where(story => story.Status == StoryStatusType.NotDone && story.Assignee.TeamAssignedTo != null).
  43. OrderBy(story => story.Title).
  44. ToList();
  45.  
  46. foreach (var story in tasksTypeStory)
  47. {
  48. taskDisplay.Append(story);
  49. }
  50. break;
  51. case "InProgres":
  52. tasksTypeStory = tasksTypeStory.
  53. Where(story => story.Status == StoryStatusType.InProgress && story.Assignee != null).
  54. OrderBy(story => story.Title).
  55. ToList();
  56.  
  57. foreach (var story in tasksTypeStory)
  58. {
  59. taskDisplay.Append(story);
  60. }
  61. break;
  62. case "Done":
  63. tasksTypeStory = tasksTypeStory.
  64. Where(story => story.Status == StoryStatusType.Done && story.Assignee != null).
  65. OrderBy(story => story.Title).
  66. ToList();
  67.  
  68. foreach (var story in tasksTypeStory)
  69. {
  70. taskDisplay.Append(story);
  71. }
  72. break;
  73. default:
  74. tasksTypeBug = tasksTypeBug.
  75. Where(bug => bug.Assignee.Name == comand && bug.Assignee != null).
  76. OrderBy(bug => bug.Title).
  77. ToList();
  78.  
  79. tasksTypeStory = tasksTypeStory.
  80. Where(story => story.Assignee.Name == comand && story.Assignee != null).
  81. OrderBy(story => story.Title).
  82. ToList();
  83.  
  84. foreach(var story in tasksTypeStory)
  85. {
  86. taskDisplay.Append(story);
  87. }
  88.  
  89. foreach(var bug in tasksTypeBug)
  90. {
  91. taskDisplay.Append(bug);
  92. }
  93.  
  94. break;
  95. }
  96.  
  97. if (taskDisplay.Length == 0)
  98. {
  99. throw new InvalidUserInputException("There is no information that meets the conditions!");
  100. }
  101.  
  102. return taskDisplay.ToString().Trim();
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement