public Task AskForTask() { var mostRecentTasks = _taskService.GetTasksByTaskIds(_timeService.GetRecentlyRecordedTaskIds(5)); _outputService.ShowInformation("Recent Tasks:"); _outputService.OutputList( mostRecentTasks.Select(x => $"{x.Name,10} {x.Description.Truncate(50),10}")); var task = AskForSpecificTask(); if (task != null) { return(task); } _outputService.ShowInformation( "Ok. Let's figure out what you are working on. We're going to list some projects."); var projects = _projectService.GetProjects().ToList(); _outputService.ShowInformation(OutputProjects(projects)); var projectKey = _inputService.AskForInput("Which project Key are you working on?"); _outputService.LoadingMessage("Getting tasks for that project. This might take a while. (especially for large projects)"); var project = _projectService.GetProjectByKey(projectKey); var tasks = _taskService.GetTasksByProject(project); _outputService.ShowInformation("Ok. We've got the tasks. Outputting the tasks for that project."); _outputService.ShowInformation(OutputTasks(tasks)); return(AskForSpecificTask()); }
public User GetUser(string apiName, string usernameKey, string passwordKey) { var username = _settingsService.GetSetting <string>(usernameKey); if (string.IsNullOrEmpty(username)) { username = _inputService.AskForInput($"Please provide your username for {apiName}"); _settingsService.SaveSetting(usernameKey, username); } var password = _settingsService.GetSetting <string>(passwordKey); if (string.IsNullOrEmpty(password)) { password = _inputService.AskForPassword($"Please provide your password for {apiName}"); _settingsService.SaveSetting(passwordKey, password); } return(new User { Username = username, Password = password }); }
Project AskAboutProject(Task currentTask) { if (currentTask?.Project != null && _inputService.AskForBoolean($"Are you still working on {currentTask.Project.Name}?")) { return(currentTask.Project); } var recentProjects = _projectService.GetProjectsByIds(_timeService.GetRecentlyRecordedProjectIds()).ToDictionary(key => key.Name); if (recentProjects.Any()) { var selectedProjectName = _inputService.AskForSelectionOrInput("Select a recent project. (Or insert a new project name)", recentProjects.Keys.ToList()); Project recentProject; if (recentProjects.TryGetValue(selectedProjectName, out recentProject)) { return(recentProject); } } if (_inputService.AskForBoolean("Do you know the name of the project you are working on?")) { var projectName = _inputService.AskForInput("What is the name?"); var project = _projectService.GetProjectByName(projectName); if (project != null) { return(project); } } var projects = _projectService.GetProjects(); return(_inputService.AskForSelection("Ok. Above is a list of projects. Which one were you working on?", projects.ToList())); }