コード例 #1
0
        // Patikrinimas ar ivestas dviracio ID sutampa
        public Tuple <bool, int> CheckMatchingBikeID()
        {
            List <Bicycle> bikes = SqlQueries.SelectBikes();

            Console.Clear();
            Console.CursorVisible = true;
            Console.WriteLine("Ivesk dviracio ID");
            while (!int.TryParse(Console.ReadLine(), out bikeID))
            {
                Console.WriteLine("\nDviracio ID sudaro tik skaitmenys! Ivesk dviracio ID");
            }

            var checkResult = bikes.Select(b => b.BikeID).Contains(bikeID);

            if (!checkResult)
            {
                Console.Clear();
                Console.WriteLine("Dviratis su tokiu ID neegzistuoja!");
                Console.ReadKey();

                isDataCorrect = false;
            }
            else
            {
                isDataCorrect = true;
            }

            return(new Tuple <bool, int>(isDataCorrect, bikeID));
        }
コード例 #2
0
        // Dviracio duomenu isvedimas i ekrana
        public void PrintAllData()
        {
            List <Bicycle> bikes = SqlQueries.SelectBikes();

            Console.Clear();
            Console.WriteLine("ID");
            Console.SetCursorPosition(10, 0);
            Console.WriteLine("Pavadinimas");
            Console.SetCursorPosition(30, 0);
            Console.WriteLine("Modelis");
            Console.SetCursorPosition(50, 0);
            Console.WriteLine("Spalva");
            Console.SetCursorPosition(70, 0);
            Console.WriteLine("Nuomos kaina");

            var result = bikes.Select(s => s).OrderBy(b => b.Brand).ThenBy(b => b.Model);

            foreach (var bike in result)
            {
                Console.SetCursorPosition(0, y);
                Console.WriteLine(bike.BikeID);
                Console.SetCursorPosition(10, y);
                Console.WriteLine(bike.Brand);
                Console.SetCursorPosition(30, y);
                Console.WriteLine(bike.Model);
                Console.SetCursorPosition(50, y);
                Console.WriteLine(bike.Color);
                Console.SetCursorPosition(70, y);
                Console.WriteLine(bike.RentPrice);
                Console.SetCursorPosition(90, y);
                y++;
            }

            Console.ReadKey();
            // Atstatoma y reiksme
            y = 2;
        }