Esempio 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();
            }
        }
Esempio n. 2
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();
            }
        }
        public static void Run()
        {
            ItemRepository Items = new ItemRepository();
            string         Choice;

            while (true)
            {
                Choice = ConsoleUtils.GetUserChoice();

                switch (Choice)
                {
                case "add":
                    string   description = ConsoleUtils.GetDescription();
                    ToDoItem Item        = new ToDoItem()
                    {
                        Description = description,
                        IsDone      = false,
                        IsPending   = false
                    };
                    Items.Create(Item);
                    break;

                case "delete":
                    int ID = ConsoleUtils.GetIdToDelete();
                    Items.Delete(ID);
                    break;

                case "mark done":
                    int DoneId = ConsoleUtils.GetIdToMarkAsDone();
                    Items.MarkAsDone(DoneId);
                    break;

                case "list pending":
                    var pending = Items.GetPendingItems();
                    ConsoleUtils.PrintTable(pending);
                    break;

                case "list done":
                    var done = Items.GetDoneItems();
                    ConsoleUtils.PrintTable(done);
                    break;

                case "list all":
                    var all = Items.GetAll();
                    ConsoleUtils.PrintTable(all);
                    break;

                case "quit":
                    return;
                }
            }
        }