Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //// c1.Wyszukanie ogłoszenia po filtrze marki/id
            //// c2.Wybór ogłoszenia z listy
            //// c3.Przedstawienie wybranego szczegółowego ogłoszenia
            ///

            MenuActionService actionService = new MenuActionService();

            actionService = Initialize(actionService);
            ItemService itemService = new ItemService();

            Console.WriteLine("Welocome in first car test&try community");
            Console.WriteLine("Select what you want to do:");


            while (true)
            {
                var mainMenu = actionService.GetMenuActionsByName("Main");
                for (int i = 0; i < mainMenu.Count; i++)
                {
                    Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}");
                }
                var operation = Console.ReadKey();

                Console.WriteLine();

                switch (operation.KeyChar)
                {
                case '1':
                    string carBrand;
                    var    keyInfo = itemService.AddNewItemView(actionService, out carBrand);
                    Console.WriteLine();
                    var id = itemService.AddNewItem(keyInfo.KeyChar, carBrand);
                    break;

                case '2':
                    var removeId = itemService.RemoveItemView();
                    Console.WriteLine();
                    itemService.RemoveItem(removeId);
                    break;

                case '3':
                    var detailId = itemService.ItemDetailSelectionView();
                    Console.WriteLine();
                    itemService.ItemDetailView(detailId);
                    break;

                case '4':
                    var brandToShow = itemService.CarBrandTypeSelectionView();
                    Console.WriteLine();
                    itemService.CarBrandsByTypeView(brandToShow);
                    break;

                default:
                    Console.WriteLine("Action you entered does not exist");
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            MenuActionService actionService = new MenuActionService();
            ItemService       itemService   = new ItemService();
            DataService       dataService   = new DataService();
            ItemManager       itemManager   = new ItemManager(actionService, itemService, dataService);

            Console.WriteLine("Welcome in first car test&try community");
            Console.WriteLine("Select what you want to do:");

            while (true)
            {
                var mainMenu = actionService.GetMenuActionsByName("Main");
                for (int i = 0; i < mainMenu.Count; i++)
                {
                    Console.WriteLine($"{mainMenu[i].Id}. {mainMenu[i].Name}");
                }
                var operation = Console.ReadKey();

                Console.WriteLine();

                switch (operation.KeyChar)
                {
                case '1':
                    itemManager.AddNewItem();
                    break;

                case '2':
                    itemManager.RemoveItem();
                    Console.WriteLine();
                    break;

                case '3':
                    itemManager.ItemDetail();
                    Console.WriteLine();
                    break;

                case '4':
                    itemManager.CarBrandsByType();
                    Console.WriteLine();
                    break;

                case '5':
                    itemManager.ShowAllCars();
                    Console.WriteLine();
                    break;

                case '6':
                    itemManager.ShowCarByCity();
                    Console.WriteLine();
                    break;

                default:
                    Console.WriteLine("Action you entered does not exist");
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public ConsoleKeyInfo AddNewItemView(MenuActionService actionService, out string carBrand)
        {
            var addNewItemMenu = actionService.GetMenuActionsByName("AddNewItemMenu");

            for (int i = 0; i < addNewItemMenu.Count; i++)
            {
                Console.WriteLine($"{addNewItemMenu[i].Id}. {addNewItemMenu[i].Name}");
            }
            var operation = Console.ReadKey();
            int carBrandChoosed;

            Int32.TryParse(operation.KeyChar.ToString(), out carBrandChoosed);
            string carBrandChosed = addNewItemMenu[carBrandChoosed - 1].Name;

            carBrand = carBrandChosed;
            return(operation);
        }