Пример #1
0
        static Car UpdateRandomCar(CarBoundContext context)
        {
            var randomCar = context.Cars.GetRandomElement();

            randomCar.Model += $" (modified {DateTime.Now}";
            context.SaveChanges();
            return(randomCar);
        }
Пример #2
0
        static Car CreateNewCar(CarBoundContext context)
        {
            var newCar = _carFactory.CreateNewRandomCar();

            context.Cars.Add(newCar);
            context.SaveChanges();
            return(newCar);
        }
Пример #3
0
        static void RemoveAllCars(CarBoundContext context)
        {
            var cars  = context.Cars;
            var count = cars.Count();

            cars.RemoveRange(cars);
            context.SaveChanges();
            Console.Clear();
            Console.WriteLine($"Removed {count} cars from repository.");
            PressAnyKey();
        }