public string Execute(IList <string> inputParameters) { string storyTitle = inputParameters[0]; string teamToAddStoryFor = inputParameters[1]; string boardToAddStoryFor = inputParameters[2]; string storyPriority = inputParameters[3]; string storySize = inputParameters[4]; string storyStatus = inputParameters[5]; string storyAssignee = inputParameters[6]; var storyDescription = descriptionBuilder.BuildDescription(inputParameters, 7); //Validations var storyTypeForChecking = "Story Title"; inputValidator.IsNullOrEmpty(storyTitle, storyTypeForChecking); var teamTypeForChecking = "Team Name"; inputValidator.IsNullOrEmpty(teamToAddStoryFor, teamTypeForChecking); var boardTypeForChecking = "Board Name"; inputValidator.IsNullOrEmpty(boardToAddStoryFor, boardTypeForChecking); inputValidator.ValdateItemTitleLength(storyTitle); inputValidator.ValdateItemDescriptionLength(storyDescription); businessLogicValidator.ValidateTeamExistance(allTeams, teamToAddStoryFor); businessLogicValidator.ValidateMemberExistance(allMembers, storyAssignee); businessLogicValidator.ValidateIfMemberNotInTeam(allTeams, teamToAddStoryFor, storyAssignee); businessLogicValidator.ValidateBoardExistanceInTeam(allTeams, boardToAddStoryFor, teamToAddStoryFor); businessLogicValidator.ValidateStoryExistanceInBoard(allTeams, boardToAddStoryFor, teamToAddStoryFor, storyTitle); //Operations var isPriorityEnumConvertable = Enum.TryParse(storyPriority, out Priority storyPriorityEnum); inputValidator.IsEnumConvertable(isPriorityEnumConvertable, "Priority"); var isSizeEnumConvertable = Enum.TryParse(storySize, out Size storySizeEnum); inputValidator.IsEnumConvertable(isSizeEnumConvertable, "Size"); var isStatusEnumConvertable = Enum.TryParse(storyStatus, out StoryStatus storyStatusEnum); inputValidator.IsEnumConvertable(isStatusEnumConvertable, "Status"); IStory storyToAddToCollection = this.factory.CreateStory(storyTitle, storyDescription, storyPriorityEnum, storySizeEnum, storyStatusEnum, allMembers.AllMembersList[storyAssignee]); var indexOfBoardInSelectedTeam = allTeams.AllTeamsList[teamToAddStoryFor].Boards.FindIndex(boardIndex => boardIndex.Name == boardToAddStoryFor); boardOperations.AddWorkitemToBoard(allTeams.AllTeamsList[teamToAddStoryFor].Boards[indexOfBoardInSelectedTeam], storyToAddToCollection); var memberToPutHistoryFor = allTeams.AllTeamsList[teamToAddStoryFor].Members.First(member => member.Name == storyAssignee); memberOpertaions.AddWorkItemIdToMember(memberToPutHistoryFor, storyToAddToCollection.Id); var boardToPutHistoryFor = allTeams.AllTeamsList[teamToAddStoryFor].Boards[indexOfBoardInSelectedTeam]; var teamToPutHistoryFor = allTeams.AllTeamsList[teamToAddStoryFor]; boardOperations.AddActivityHistoryToBoard(allTeams.AllTeamsList[teamToAddStoryFor].Boards[indexOfBoardInSelectedTeam], memberToPutHistoryFor, storyToAddToCollection); memberOpertaions.AddActivityHistoryToMember(memberToPutHistoryFor, storyToAddToCollection, teamToPutHistoryFor, boardToPutHistoryFor); return(string.Format(StoryCreated, storyTitle)); }
public string Execute(IList <string> inputParameters) { string bugTitle = inputParameters[0]; string teamToAddBugFor = inputParameters[1]; string boardToAddBugFor = inputParameters[2]; string bugPriority = inputParameters[3]; string bugSeverity = inputParameters[4]; string bugAssignee = inputParameters[5]; IList <string> bugStepsToReproduce = stepsToReproduceBuilder.BuildStepsToReproduce(inputParameters, "!Steps"); var bugDescription = descriptionBuilder.BuildDescription(inputParameters, "!Steps"); //Validations var bugTypeForChecking = "Bug Title"; inputValidator.IsNullOrEmpty(bugTitle, bugTypeForChecking); var teamTypeForChecking = "Team Name"; inputValidator.IsNullOrEmpty(teamToAddBugFor, teamTypeForChecking); var boardTypeForChecking = "Board Name"; inputValidator.IsNullOrEmpty(boardToAddBugFor, boardTypeForChecking); inputValidator.ValdateItemTitleLength(bugTitle); inputValidator.ValdateItemDescriptionLength(bugDescription); businessLogicValidator.ValidateTeamExistance(allTeams, teamToAddBugFor); businessLogicValidator.ValidateMemberExistance(allMembers, bugAssignee); businessLogicValidator.ValidateIfMemberNotInTeam(allTeams, teamToAddBugFor, bugAssignee); businessLogicValidator.ValidateBugExistanceInBoard(allTeams, boardToAddBugFor, teamToAddBugFor, bugTitle); //Operations var isPriorityEnumConvertable = Enum.TryParse(bugPriority, out Priority bugPriorityEnum); inputValidator.IsEnumConvertable(isPriorityEnumConvertable, "Priority"); var isSeverityEnumConvertable = Enum.TryParse(bugSeverity, out Severity bugSeverityEnum); inputValidator.IsEnumConvertable(isSeverityEnumConvertable, "Severity"); IBug bugToAddToCollection = this.factory.CreateBug(bugTitle, bugPriorityEnum, bugSeverityEnum, allMembers.AllMembersList[bugAssignee], bugStepsToReproduce, bugDescription); var indexOfBoardInSelectedTeam = allTeams.AllTeamsList[teamToAddBugFor].Boards.FindIndex(boardIndex => boardIndex.Name == boardToAddBugFor); boardOperations.AddWorkitemToBoard(allTeams.AllTeamsList[teamToAddBugFor].Boards[indexOfBoardInSelectedTeam], bugToAddToCollection); var memberToTrackActivityFor = allTeams.AllTeamsList[teamToAddBugFor].Members.First(member => member.Name == bugAssignee); memberOpertaions.AddWorkItemIdToMember(memberToTrackActivityFor, bugToAddToCollection.Id); var boardToPutHistoryFor = allTeams.AllTeamsList[teamToAddBugFor].Boards[indexOfBoardInSelectedTeam]; var teamToPutHistoryFor = allTeams.AllTeamsList[teamToAddBugFor]; boardOperations.AddActivityHistoryToBoard(allTeams.AllTeamsList[teamToAddBugFor].Boards[indexOfBoardInSelectedTeam], memberToTrackActivityFor, bugToAddToCollection); memberOpertaions.AddActivityHistoryToMember(memberToTrackActivityFor, bugToAddToCollection, teamToPutHistoryFor, boardToPutHistoryFor); return(string.Format(BugCreated, bugTitle)); }