Exemplo n.º 1
0
        public void ProcessInput()
        {
            //Display menu
            DisplayALL();
            Console.WriteLine();
            string AppAction = ConsoleUtils.DisplayMenu();

            while (AppAction != "Exit")
            {
                switch (AppAction)
                {
                case "List":
                    DisplayALL();
                    break;

                case "Add":
                    string[] newItemInfo = ConsoleUtils.ItemUserInput();
                    repo.AddItem(newItemInfo[0], newItemInfo[1]);    //DateTime.Parse(newItem[2])
                    DisplayALL();
                    break;

                case "Delete":
                    //ask usr for id
                    int itemID = ConsoleUtils.GetItemID();
                    //remove
                    repo.DeleteItem(itemID);
                    DisplayALL();
                    break;

                case "Update":
                    itemID = ConsoleUtils.GetItemID();
                    string[] updatedItemInfo = ConsoleUtils.ItemUserInput();
                    repo.UpdateItem(itemID, updatedItemInfo[0], updatedItemInfo[1]);    //, DateTime.Parse(updatedItem[2])
                    DisplayALL();
                    break;

                case "Pending":
                    ConsoleUtils.PrintAllItems(repo.GetPendingItems());
                    Console.WriteLine();
                    DisplayALL();
                    break;

                case "Done":
                    ConsoleUtils.PrintAllItems(repo.GetPendingItems());
                    Console.WriteLine();
                    DisplayALL();
                    break;

                case "Exit":
                    DisplayALL();
                    ConsoleUtils.QuitProgram();
                    break;

                default:
                    Console.WriteLine("You have entered an invalid option. Please try again.");
                    break;
                }
                AppAction = ConsoleUtils.DisplayMenu();
            }
        }
Exemplo n.º 2
0
        public void Start()
        {
            bool isRunning = true;

            while (isRunning)
            {
                var response = consoleUtils.UtilGetUserOption();
                switch (response)
                {
                case 1:     //Add ToDoItem
                    itemRepository.AddItem(consoleUtils.UtilAddItem());
                    break;

                case 2:     // Delete ToDoItem
                    if (itemRepository.CheckItem(consoleUtils.UtilGetItem()) == true)
                    {
                        itemRepository.RemoveItem(consoleUtils.UtilGetItem());
                    }
                    else
                    {
                        consoleUtils.UtilError();
                    }

                    break;

                case 3:     // Mark a ToDoItem as Done

                    if (itemRepository.CheckItem(consoleUtils.UtilGetItem()) == true)
                    {
                        itemRepository.MarkDoneItem(consoleUtils.UtilGetItem());
                    }
                    else
                    {
                        consoleUtils.UtilError();
                    }
                    break;

                case 4:     //List all ToDoItems
                    consoleUtils.UtilPrintList(itemRepository.GetAllItem());
                    break;

                case 5:     //List all Done ToDoItems
                    consoleUtils.UtilPrintList(itemRepository.GetDoneItem());
                    break;

                case 6:     //List all Pending ToDoItems
                    consoleUtils.UtilPrintList(itemRepository.GetPendingItem());
                    break;

                case 7:
                    isRunning = false;
                    break;

                case 8:
                    consoleUtils.UtilError();
                    break;
                }
            }
        }
Exemplo n.º 3
0
        public void ProcessInput()
        {
            //Display menu
            //DisplayALL();
            string action = ConsoleUtils.DisplayMenu();

            while (action != "Exit")
            {
                switch (action)
                {
                case "List":
                    DisplayALL();
                    break;

                case "Add":
                    string[] newItem = ConsoleUtils.ItemUserInput();
                    repo.AddItem(newItem[0], newItem[1]);
                    DisplayALL();
                    break;

                case "Delete":

                    int itemID = ConsoleUtils.GetItemID();

                    repo.DeleteItem(itemID);
                    DisplayALL();
                    break;

                case "Edit":
                    itemID = ConsoleUtils.GetItemID();
                    string[] updatedItem = ConsoleUtils.ItemUserInput();
                    repo.UpdateItem(itemID, updatedItem[0], updatedItem[1]);
                    DisplayALL();
                    break;

                case "Pending":
                    repo.GetPendingItems();
                    Console.WriteLine();
                    DisplayALL();
                    break;

                case "Done":
                    repo.GetDoneItems();
                    Console.WriteLine();
                    DisplayALL();
                    break;

                case "Exit":
                    DisplayALL();
                    Console.WriteLine("You have now quit the program");
                    break;

                default:
                    Console.WriteLine("You have entered an invalid option. Please try again.");
                    break;
                }
                action = ConsoleUtils.DisplayMenu();
            }
        }
Exemplo n.º 4
0
        public void Start()
        {
            string   desc = utils.EnterItemDescription();
            DateTime due  = utils.EnterDueDate();

            ToDoItem item = new ToDoItem(desc, false, due);

            repo.AddItem(item);
        }
Exemplo n.º 5
0
        public void Run()
        {
            string answer = ConsoleUtils.DisplayMenu(); //UI and Menu Display after string

            while (answer != "Q")
            {
                if (answer == "L")
                {
                    repo.GetToDoItems();
                    List <ToDoItems> list = repo.GetToDoItems();
                    ConsoleUtils.PrintToDoItems(list);
                }
                if (answer == "A")
                {
                    Console.WriteLine("Add a Description: ");
                    string Description = Console.ReadLine(); //strings for input
                    Console.WriteLine("Enter a Importance Status for item: (Low, Medium, High) ");
                    string Status = Console.ReadLine();
                    Console.WriteLine("Enter a Due Date: month/day/year ");
                    DateTime DueDate = Convert.ToDateTime(Console.ReadLine());
                    repo.AddItem(Description, Status, DueDate);
                }
                if (answer == "U")
                {
                    Console.WriteLine(" What is the ID of what needs to be updated: ");
                    int Id = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Update your Description of the item: ");
                    string Description = Console.ReadLine();
                    Console.WriteLine("Update Importance Status of the item: ");
                    string Status = Console.ReadLine();
                    Console.WriteLine("Update your due date of the item: ");
                    DateTime DueDate = Convert.ToDateTime(Console.ReadLine());
                    repo.UpdateItem(Id, Description, Status, DueDate);
                }
                if (answer == "R")
                {
                    Console.WriteLine("What is the ID of the item you want to Delete: ");
                    int Id = Convert.ToInt32(Console.ReadLine());
                    repo.DeleteItem(Id);
                }
                answer = ConsoleUtils.DisplayMenu();
            }
        }
Exemplo n.º 6
0
        //Main driving method
        public void Start()
        {
            //Calls DisplayAll method as well as the command list.
            DisplayAll();
            string command      = ConsoleUtil.GetCommands();
            bool   quit         = false;
            bool   update       = false;
            string updateSelect = "";
            bool   verifyID     = true;
            bool   verifyStat   = true;

            //While the program is not in a "quit" state then run
            while (!quit)
            {
                //Ensures that the command given is actually valid
                CommandValidate(command);
                if (CommandValidate(command) == false)
                {
                    ConsoleUtil.BadAction();
                }

                //Switch statement handles command scenarios
                switch (command)
                {
                //Asks user for description of ToDo Item
                //Once done, the item is generated and added to the list
                case "Add":
                    update = true;
                    string newDesc = ConsoleUtil.GetDescription(update);
                    ItemRepository.AddItem(newDesc);
                    DisplayAll();
                    break;

                case "Delete":
                    do
                    {
                        //Asks user to select ID and verifies ID to ensure it's valid.
                        int delItemID = ConsoleUtil.GetItemID(command);
                        verifyID = Itemrepo.ItemIDVerify(delItemID);
                        if (verifyID == false)
                        {
                            //If not valid, then calls BadID method
                            DisplayAll();
                            ConsoleUtil.BadID();
                        }
                        else
                        {
                            //If valid then call DeleteItem method with given ID
                            //Then display updated list
                            Itemrepo.DeleteItem(delItemID);
                            DisplayAll();
                        }
                        //Ensures that this case is looped while ID is invalid
                    } while (!verifyID);
                    break;

                case "Update":
                    do
                    {
                        update = true;
                        //User is asked to select an ID to update
                        int itemID = ConsoleUtil.GetItemID(command);
                        //Verifies ID is valid
                        verifyID = Itemrepo.ItemIDVerify(itemID);
                        if (verifyID == false)
                        {
                            //If not, call BadID method to prompt user
                            ConsoleUtil.BadID();
                        }
                        else
                        {
                            //If ID is valid, prompts user to select either "description" or "status" to update
                            updateSelect = ConsoleUtil.UpdateSelect(itemID);

                            if (updateSelect == "description")
                            {
                                //If "description" is selected then automatically set the status update to false
                                bool statUpdate = false;
                                //Grabs new description
                                newDesc = ConsoleUtil.GetDescription(update);
                                //Status stays the same
                                string newStat = ConsoleUtil.GetStatus(statUpdate);
                                //Generates updated ToDo Itm
                                Itemrepo.UpdateItem(itemID, newDesc, newStat);
                            }
                            else if (updateSelect == "status")
                            {
                                do
                                {
                                    //If status is to be updated
                                    //Automatically sets "description" update to false
                                    bool descUpdate = false;
                                    //Prompts user for new status and grabs string
                                    string newStat = ConsoleUtil.GetStatus(update);
                                    //Verifies that it is a valid status
                                    verifyStat = StatusValidate(newStat);
                                    if (verifyStat == false)
                                    {
                                        //If not a valid status, prompts user to Bad Status
                                        ConsoleUtil.BadStatus();
                                    }
                                    else
                                    {
                                        //If valid then description stays the same then generates updated ToDo Item
                                        newDesc = ConsoleUtil.GetDescription(descUpdate);
                                        Itemrepo.UpdateItem(itemID, newDesc, newStat);
                                    }
                                    //While loop ensures that case is looped while an invalid status persists
                                } while (verifyStat == false);
                            }
                            //Anything other than "description" or "status" will result in the invalid action prompt
                            //And sets the verifyID to false so the case will get looped again
                            else
                            {
                                ConsoleUtil.BadAction();
                                verifyID = false;
                            }
                        }
                        //While loop ensures Update case is looped while ID is invalid
                    } while (!verifyID);
                    //Displays the list with updated items
                    DisplayAll();
                    break;

                case "Filter":
                    //Runs DisplayFilter method and that method handles everything for this case
                    DisplayFilter();
                    break;

                case "Quit":
                    //Calls the QuitProtocol and sets quit to be true so it can exit out of the program loop
                    Itemrepo.QuitProtocol();
                    quit = true;
                    break;
                }
                if (quit == true)
                {
                    //Then prompts user with exit message
                    ConsoleUtil.QuitMessage();
                }
                else
                {
                    //Still uses the program then displays commands
                    command = ConsoleUtil.GetCommands();
                }
            }
        }
Exemplo n.º 7
0
        public void Menu()
        {
            bool isRunning = true;

            while (isRunning)
            {
                Console.Clear();
                consoleUtils.MainMenu();
                int choice = consoleUtils.UserOption();

                if (choice == 1)                                    //Add an item to list
                {
                    itemRepository.AddItem(consoleUtils.AddItem());
                }
                else if (choice == 2)                               //Delete an item
                {
                    consoleUtils.Print(itemRepository.PrintAll());
                    int id = consoleUtils.DeleteItem();
                    if (itemRepository.IdChecker(id))
                    {
                        itemRepository.DeleteItem(id);
                    }
                    else
                    {
                        consoleUtils.InvalidInput();
                    }
                }
                else if (choice == 3)                               //Mark an item as complete
                {
                    consoleUtils.Print(itemRepository.PrintAll());
                    int id = consoleUtils.ChangeItem();

                    if (itemRepository.IdChecker(id))
                    {
                        itemRepository.ChangeItem(id);
                    }
                    else
                    {
                        consoleUtils.InvalidInput();
                    }
                }
                else if (choice == 4)                               //Print pending items
                {
                    consoleUtils.Print(itemRepository.PrintPending());
                    Console.ReadKey();
                }
                else if (choice == 5)                               //Print completed items
                {
                    consoleUtils.Print(itemRepository.PrintComplete());
                    Console.ReadKey();
                }
                else if (choice == 6)                               //Print all Items
                {
                    consoleUtils.Print(itemRepository.PrintAll());
                    Console.ReadKey();
                }
                else if (choice == 7)                               //Quit the app
                {
                    isRunning = false;
                }
            }
        }
Exemplo n.º 8
0
 public void AddItem(string Description, string Status, string DueDate)
 {
     repo.AddItem(Description, DueDate, Status);
 }
Exemplo n.º 9
0
 public void Add(string item)
 {
     DisplayMessage(ItemRepository.AddItem(item)); //call add method and display returned string "Message"
 }