Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Linq;
- using WIMS.Commands;
- using WIMS.Commands.Contracts;
- using WIMS.Core.Contracts;
- using WIMS.Core.Factory;
- using WIMS.Models.Enums;
- public class CreateBugCommand : ICommand
- {
- private readonly IWIMSFactory factory;
- private readonly IEngine engine;
- public CreateBugCommand(IWIMSFactory factory, IEngine engine)
- {
- this.factory = factory;
- this.engine = engine;
- }
- public string Execute(IList<string> parameters)
- {
- //if (parameters.Count != 2)
- //{
- // throw new Exception("Parameters count is not valid!");
- //}
- //else
- //{
- // string title;
- // string description;
- // try
- // {
- // title = parameters[0].ToString();
- // description = parameters[1].ToString();
- // }
- // catch (Exception) //ex???
- // {
- // throw new ArgumentException("Failed to parse CreateBug command parameters.");
- // }
- // var bug = this.factory.CreateBugCommand(title, description);
- // this.engine.WorkItemsList.Add(bug);
- // return bug.Print();
- //}
- //string title = string.Empty;
- //string description = string.Empty;
- List<string> stepsList = new List<string>();
- Enum priority = default;
- Enum severity = default;
- Enum status = default;
- string title = string.Empty;
- string description = string.Empty;
- string input = string.Empty;
- if (parameters.Count == 0)
- {
- Tuple<string, string> list = (Guard.ValidateInput("", ""));
- title = list.Item1;
- description = list.Item2;
- Console.WriteLine("Please enter a number of lines (steps), which you would like follow.");
- while (true)
- {
- if (!int.TryParse(Console.ReadLine(), out int stepsNumber))
- {
- Console.WriteLine("Number ot steps should be a positive number!");
- continue;
- }
- for (int i = 1; i <= stepsNumber; i++)
- {
- Console.WriteLine($"Please enter a step number {i}:");
- stepsList.Add(Console.ReadLine());
- }
- break;
- }
- Console.WriteLine($"Please enter one of the following options for Priority:\nHigh/Medium/Low");
- priority = Guard.ValideEnum(string.Empty);
- Console.WriteLine($"Please enter one of the following options for Severity:\nCritical/Major/Minor");
- severity = Guard.ValideEnum(string.Empty);
- Console.WriteLine($"Please enter one of the following options for Bug Status:\nCritical/Major/Minor");
- status = Guard.ValideEnum(string.Empty);
- }
- else
- {
- Console.WriteLine("Create Bug command should be followed by other parameters one by line.");
- }
- var bug = this.factory.CreateBugCommand(title, description,stepsList, (Priority)priority,(Severity)severity, (BugStatus)status);
- this.engine.WorkItemsList.Add(bug);
- //Console.WriteLine($"Do you want to assign this Bug to a specific Board?\n Yes/No");
- //var assignBugOrNot = Console.ReadLine().ToLower();
- //while (true)
- //{
- // if (assignBugOrNot == "yes")
- // {
- // this.engine.AssignWorkItemToMember
- // break;
- // }
- // else if (assignBugOrNot == "no")
- // {
- // break;
- // }
- // else
- // {
- // Console.WriteLine("Please choose one of the options above!");
- // continue;
- // }
- //}
- return bug.Print();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment