Пример #1
0
        public AppConsoleView(IRecordController controller)
        {
            Controller = controller;

            MainMenu = new ConsoleMenu("Main menu:", new List <ConsoleMenuOption>()
            {
                new ConsoleMenuOption("Print records", PrintRecords),
                new ConsoleMenuOption("Add record", AddRecord),
                new ConsoleMenuOption("Delete record", DeleteRecord),
                new ConsoleMenuOption("Exit", () => { Environment.Exit(0); })
            });
        }
Пример #2
0
        private void AddRecord()
        {
            var addMenuOptions = new List <ConsoleMenuOption>()
            {
                new ConsoleMenuOption("Message", AddMessageRecord),
                new ConsoleMenuOption("Person", AddPersonRecord),
                new ConsoleMenuOption("Car", AddCarRecord),
            };

            var addMenu = new ConsoleMenu("Choose record type to add:", addMenuOptions);

            addMenu.RenderAndProcessAction();
        }
Пример #3
0
        private void DeleteRecord()
        {
            var deleteMenuOptions = Controller.Records.Select(record =>
                                                              new ConsoleMenuOption(record.ToString(), () => Controller.DeleteRecord(record))
                                                              ).ToList();

            var deleteMenuHeader = deleteMenuOptions.Any() ? "Choose record to delete:" : "There are no records to delete.";

            deleteMenuOptions.Add(new ConsoleMenuOption("Return to the main menu", () => { }));

            var deleteMenu = new ConsoleMenu(deleteMenuHeader, deleteMenuOptions);

            deleteMenu.RenderAndProcessAction();
        }