Ejemplo n.º 1
0
        public static Task AddOrEdit(Task task, bool edit = false)
        {
            string name = "name", newDescription, newDueDate;

            if (task == null)
            {
                task = new Task();
            }
            List <Member> newMembers = new List <Member>();

            newMembers = task.memberList;

            while (name != string.Empty)
            {
                Console.Write("\n\nAdd a new owner or ENTER to quit: ");

                name = Console.ReadLine();
                if (name != string.Empty)
                {
                    newMembers.Add(new Member(name));
                }
            }
            if (edit)
            {
                newDescription = UserInput.GetUserInput("Press Enter to keep old descrpition: ", false);
                newDueDate     = UserInput.GetUserInputAsDate("Press Enter to keep old deadline: ", false);

                if (newDueDate != string.Empty)
                {
                    task.dueDate = newDueDate;
                }

                if (newDescription != string.Empty)
                {
                    task.description = newDescription;
                }
            }
            else
            {
                newDescription = UserInput.GetUserInput("Description: ");
                newDueDate     = UserInput.GetUserInputAsDate("Deadline: ");
                return(new Task(newDescription, newDueDate, newMembers));
            }
            return(task);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return true if user input equals trueOption. trueOption set to "Y" by default.
        /// </summary>
        /// <param name="message"></param>
        public static bool UserConfirmationPrompt(string message, string trueOption = "Y", string falseOption = "N")
        {
            string input = UserInput.GetUserInput(message);

            if (new Regex($"{trueOption}", RegexOptions.IgnoreCase).IsMatch(input))
            {
                return(true);
            }

            if (new Regex($"{falseOption}", RegexOptions.IgnoreCase).IsMatch(input))
            {
                return(false);
            }
            else
            {
                return(UserConfirmationPrompt(message));
            }
        }
Ejemplo n.º 3
0
        private static void DisplayTasksByOwnerName(List <Task> taskList)
        {
            List <Task> employeeTasks = FindMemberTasks(taskList,
                                                        UserInput.GetUserInput("Enter some or all of employees name: "));

            if (employeeTasks.Count > 0)
            {
                UserInput.Display($"({employeeTasks.Count}) result(s) found.");

                foreach (Task task in employeeTasks)
                {
                    task.DisplayTask();
                }
            }
            else
            {
                UserInput.Display("Nothing found....");
            }
        }