Beispiel #1
0
        internal static void Add()
        {
            bool exitMenuAdd = false;

            ConsoleKey selectCreateditem = ConsoleKey.Q;

            List <string> aboutItemCatalog;

            while (!exitMenuAdd)
            {
                Console.Clear();
                Screen.ShowText(Titles.MenuToAdd);
                selectCreateditem = Console.ReadKey().Key;
                aboutItemCatalog  = Screen.Input(selectCreateditem);

                switch (selectCreateditem)
                {
                case ConsoleKey.D1:
                case ConsoleKey.NumPad1:
                {
                    Catalog.Add(new Library.Book(aboutItemCatalog));
                    exitMenuAdd = true;
                    break;
                }

                case ConsoleKey.D2:
                case ConsoleKey.NumPad2:
                {
                    Catalog.Add(new Library.Newspaper(aboutItemCatalog));
                    exitMenuAdd = true;
                    break;
                }

                case ConsoleKey.D3:
                case ConsoleKey.NumPad3:
                {
                    Catalog.Add(new Library.Patent(aboutItemCatalog));
                    exitMenuAdd = true;
                    break;
                }

                case ConsoleKey.Q:
                {
                    exitMenuAdd = true;
                    break;
                }

                default:
                    break;
                }
            }

            if (MainMenu.ConditionToAdd(selectCreateditem))
            {
                Console.Clear();
                Screen.ShowResultAddOrEdit(Catalog.AllItem[Catalog.Count - 1]);
                Console.ReadKey();
            }
        }
Beispiel #2
0
        internal static void SortByYear()
        {
            Console.Clear();

            ConsoleKey selectSortMenu = ConsoleKey.A;

            if (Catalog.IsNotEmpty)
            {
                bool exitSortYear = false;
                List <ItemCatalog> catalogAfterSort = new List <ItemCatalog>();
                var info = string.Empty;

                while (!exitSortYear)
                {
                    Console.Clear();
                    Screen.ShowText(Titles.MenuToSortYear);
                    selectSortMenu = Console.ReadKey().Key;

                    Sorter.Sorting sortByYear = null;

                    switch (selectSortMenu)
                    {
                    case ConsoleKey.D1:
                    case ConsoleKey.NumPad1:

                        sortByYear       = Sorter.SortByYearASC;
                        catalogAfterSort = Sorter.Sort(sortByYear, Catalog.AllItem);

                        exitSortYear = true;
                        break;

                    case ConsoleKey.D2:
                    case ConsoleKey.NumPad2:

                        sortByYear       = Sorter.SortByYearDESC;
                        catalogAfterSort = Sorter.Sort(sortByYear, Catalog.AllItem);

                        exitSortYear = true;
                        break;

                    case ConsoleKey.Q:
                        exitSortYear = true;
                        break;

                    default:
                        break;
                    }
                }

                if (MainMenu.ConditionToAdd(selectSortMenu))
                {
                    Console.Clear();
                    info = Catalog.GetInfoSelectedItem(catalogAfterSort);
                    Screen.ShowText(Titles.ShowCatalog, info, Titles.PressAnyKey);
                }
            }
            else
            {
                Screen.ShowText(Titles.EmptyCatalog);
            }

            if (selectSortMenu != ConsoleKey.Q)
            {
                Console.ReadKey();
            }
        }