nassss

Untitled

Feb 16th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Linq;
  5. using WIMS.Commands;
  6. using WIMS.Commands.Contracts;
  7. using WIMS.Core.Contracts;
  8. using WIMS.Core.Factory;
  9. using WIMS.Models.Enums;
  10.  
  11. public class CreateBugCommand : ICommand
  12. {
  13. private readonly IWIMSFactory factory;
  14. private readonly IEngine engine;
  15.  
  16. public CreateBugCommand(IWIMSFactory factory, IEngine engine)
  17. {
  18. this.factory = factory;
  19. this.engine = engine;
  20. }
  21.  
  22. public string Execute(IList<string> parameters)
  23. {
  24. //if (parameters.Count != 2)
  25. //{
  26. // throw new Exception("Parameters count is not valid!");
  27. //}
  28. //else
  29. //{
  30. // string title;
  31. // string description;
  32. // try
  33. // {
  34. // title = parameters[0].ToString();
  35.  
  36. // description = parameters[1].ToString();
  37. // }
  38. // catch (Exception) //ex???
  39. // {
  40. // throw new ArgumentException("Failed to parse CreateBug command parameters.");
  41. // }
  42.  
  43. // var bug = this.factory.CreateBugCommand(title, description);
  44. // this.engine.WorkItemsList.Add(bug);
  45.  
  46. // return bug.Print();
  47. //}
  48. //string title = string.Empty;
  49. //string description = string.Empty;
  50.  
  51. List<string> stepsList = new List<string>();
  52. Enum priority = default;
  53. Enum severity = default;
  54. Enum status = default;
  55. string title = string.Empty;
  56. string description = string.Empty;
  57. string input = string.Empty;
  58. if (parameters.Count == 0)
  59. {
  60. Tuple<string, string> list = (Guard.ValidateInput("", ""));
  61. title = list.Item1;
  62. description = list.Item2;
  63.  
  64. Console.WriteLine("Please enter a number of lines (steps), which you would like follow.");
  65.  
  66. while (true)
  67. {
  68. if (!int.TryParse(Console.ReadLine(), out int stepsNumber))
  69. {
  70. Console.WriteLine("Number ot steps should be a positive number!");
  71. continue;
  72. }
  73. for (int i = 1; i <= stepsNumber; i++)
  74. {
  75. Console.WriteLine($"Please enter a step number {i}:");
  76. stepsList.Add(Console.ReadLine());
  77. }
  78. break;
  79. }
  80.  
  81.  
  82. Console.WriteLine($"Please enter one of the following options for Priority:\nHigh/Medium/Low");
  83. priority = Guard.ValideEnum(string.Empty);
  84.  
  85. Console.WriteLine($"Please enter one of the following options for Severity:\nCritical/Major/Minor");
  86. severity = Guard.ValideEnum(string.Empty);
  87.  
  88. Console.WriteLine($"Please enter one of the following options for Bug Status:\nCritical/Major/Minor");
  89. status = Guard.ValideEnum(string.Empty);
  90. }
  91. else
  92. {
  93. Console.WriteLine("Create Bug command should be followed by other parameters one by line.");
  94. }
  95.  
  96. var bug = this.factory.CreateBugCommand(title, description,stepsList, (Priority)priority,(Severity)severity, (BugStatus)status);
  97. this.engine.WorkItemsList.Add(bug);
  98.  
  99. //Console.WriteLine($"Do you want to assign this Bug to a specific Board?\n Yes/No");
  100. //var assignBugOrNot = Console.ReadLine().ToLower();
  101.  
  102. //while (true)
  103. //{
  104. // if (assignBugOrNot == "yes")
  105. // {
  106. // this.engine.AssignWorkItemToMember
  107. // break;
  108. // }
  109. // else if (assignBugOrNot == "no")
  110. // {
  111. // break;
  112. // }
  113. // else
  114. // {
  115. // Console.WriteLine("Please choose one of the options above!");
  116. // continue;
  117. // }
  118. //}
  119.  
  120. return bug.Print();
  121.  
  122. }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment