Ejemplo n.º 1
0
        static Car UpdateRandomCar(CarBoundContext context)
        {
            var randomCar = context.Cars.GetRandomElement();

            randomCar.Model += $" (modified {DateTime.Now}";
            context.SaveChanges();
            return(randomCar);
        }
Ejemplo n.º 2
0
        static Car CreateNewCar(CarBoundContext context)
        {
            var newCar = _carFactory.CreateNewRandomCar();

            context.Cars.Add(newCar);
            context.SaveChanges();
            return(newCar);
        }
Ejemplo n.º 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();
        }