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; } }
public void DeleteAutoFromInventoryTable() { var cars = new CarsDb(); cars.OpenConnection(ConnectionString); var carId = InsertTestAutoInTheInventoryTable(cars); cars.DeleteAuto(carId); Assert.IsFalse(cars.IsPresentId("Inventory", carId)); cars.CloseConnection(); }
public void PresentId( [Values("Inventory", "Customers")] string tableDb) { var cars = new CarsDb(); cars.OpenConnection(ConnectionString); var dataTable = cars.GetAllFrom(tableDb); var firstRow = dataTable.Rows[0]; var firstId = (int)firstRow[0]; Assert.IsTrue(cars.IsPresentId(tableDb, firstId)); cars.CloseConnection(); }