Ejemplo n.º 1
0
        private static void FirstCarByColor()
        {
            var car = Dal.GetCar(_cars.OrderBy(x => x.Color).Select(x => x.CarId).First());

            Console.WriteLine("***First Car By Color***");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}");
            Console.WriteLine("*********************");
        }
Ejemplo n.º 2
0
        public static void DalTest()
        {
            var dal  = new InventoryDal();
            var list = dal.GetAllInventory();

            Console.WriteLine("***** All Cars ******");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            foreach (var item in list)
            {
                Console.WriteLine($"{item.CarId}\t{item.Make}\t{item.Color}\t{item.PetName}");
            }

            Console.WriteLine();
            var car = dal.GetCar(list.OrderBy(x => x.Color).Select(x => x.CarId).First());

            Console.WriteLine("***** First Car by Color ********");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{car.CarId}\t{car.Make}\t{car.Color}\t{car.PetName}");

            try
            {
                dal.DeleteCar(5);
                Console.WriteLine("Car deleted");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"An exception occured: {ex.Message}");
            }

            dal.InsertAuto(new Car {
                Color = "Blue", Make = "Pilot", PetName = "TownMonster"
            });
            list = dal.GetAllInventory();
            var newCar = list.First(x => x.PetName == "TownMonster");

            Console.WriteLine("***** New Car ********");
            Console.WriteLine("CarId\tMake\tColor\tPet Name");
            Console.WriteLine($"{newCar.CarId}\t{newCar.Make}\t{newCar.Color}\t{newCar.PetName}");

            dal.DeleteCar(newCar.CarId);
            var petName = dal.LookUpPetName(car.CarId);

            Console.WriteLine($"Car pet name: {petName}");
            Console.WriteLine("Press Enter to continue...");
            Console.ReadLine();
        }