static Car UpdateRandomCar(CarBoundContext context) { var randomCar = context.Cars.GetRandomElement(); randomCar.Model += $" (modified {DateTime.Now}"; context.SaveChanges(); return(randomCar); }
static Car CreateNewCar(CarBoundContext context) { var newCar = _carFactory.CreateNewRandomCar(); context.Cars.Add(newCar); context.SaveChanges(); return(newCar); }
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(); }