Пример #1
0
        //public void presentAddFlatPage()
        //{
        //    RoomsManager manager = new RoomsManager();
        //    manager.addRoom();
        //    Console.WriteLine("Your room was successfully added");
        //}
        public void presentFilters()
        {
            RoomFilter filter = new RoomFilter();
            Console.Clear();
            Console.WriteLine("1. Search for rooms count");
            Console.Write("2. Search for price\nYour choise ");
            string selection = Console.ReadLine();

            if (selection == "1")
            {
                Console.Clear();
                Console.Write("Enter rooms count ");
                string count = Console.ReadLine();

                List<Flat> filteredFlats = filter.searchWithRoomCountInArray(count, flats);
                Console.Clear();
                if (!presentFlatsFromArray(filteredFlats))
                    return;

                Console.WriteLine("Please, select interesting postion");
                string index = Console.ReadLine();
                try
                {
                    Flat flat = flats[Int16.Parse(index) - 1];
                    printSelectedFlat(flat);
                }
                catch
                {
                    Console.WriteLine("Incorrect index");
                }

            }
            else if( selection == "2")
            {
                Console.Clear();
                Console.Write("Enter price ");
                string price = Console.ReadLine();

                List<Flat> filteredFlats = filter.searchWithPriceInArray(price, flats);
                Console.Clear();
                if(!presentFlatsFromArray(filteredFlats))
                    return;

                Console.WriteLine("Please, select interesting postion");
                string index = Console.ReadLine();
                try
                {
                    Flat flat = flats[Int16.Parse(index)];
                    printSelectedFlat(flat);
                }
                catch
                {
                    Console.WriteLine("Incorrect index");
                }
            }
            else
            {
                Console.WriteLine("Incorrect index");
            }
        }
Пример #2
0
 public Menu()
 {
     dataSource = new XMLFileOperator("file.xml");
     flats = dataSource.getAllFlatsFromXml();
     filter = new RoomFilter();
 }