예제 #1
0
        private static void InsertAuto()
        {
            while (true)
            {
                TryConnectTo(CarsDb);
                System.Console.WriteLine("Enter new CarId: ");
                var enteredText = GetNotNullOrEmptyInputText();
                _carId = ParseStringToNumber(enteredText);
                if (CarsDb.IsPresentId("Inventory", _carId))
                {
                    const string errorMessage = "This id is using. Try again";
                    PrintColored(errorMessage, ErrorForegroungColor);
                    continue;
                }
                System.Console.WriteLine("Enter new Name: ");
                _name = GetNotNullOrEmptyInputText();
                System.Console.WriteLine("Enter new Color: ");
                _color = GetNotNullOrEmptyInputText();
                System.Console.WriteLine("Enter new Make: ");
                _make = GetNotNullOrEmptyInputText();
                System.Console.WriteLine("Enter new PetName: ");
                _petName = GetNotNullOrEmptyInputText();

                CarsDb.InsertAuto(_carId, _name, _color, _make, _petName);
                CarsDb.CloseConnection();
                const string okMessage = "You have add new car!";
                PrintColored(okMessage, OkForegroungColor);
                break;
            }
        }
예제 #2
0
        private static int InsertTestAutoInTheInventoryTable(CarsDb carsDb)
        {
            var dataTable = carsDb.GetAllFrom("Inventory");
            var carId     = GenerateNewUnicIdInTheTable(dataTable);

            carsDb.InsertAuto(carId, "n", "c", "m", "p");
            return(carId);
        }