private void ConfigureGrid() { using var repo = new CarRepo(_context); // Build a LINQ query that gets back some data from the Inventory table. gridInventory.ItemsSource = repo.GetAllIgnoreQueryFilters().ToList() .Select(x => new { x.Id, Make = x.MakeName, x.Color, x.PetName }); }
public MainWindowViewModel() { ApplicationDbContext context = ConfigurationHelpers.GetContext(ConfigurationHelpers.GetConfiguration()); ICarRepo carRepo = new CarRepo(context); Cars = new ObservableCollection <Car>(carRepo.GetAllIgnoreQueryFilters()); }
private static void RemoveRecordById(int carId, byte[] timeStamp) { using (var repo = new CarRepo()) { repo.Delete(carId, timeStamp); } }
private static void UpdateRecordWithConcurrency() { //simulate two different users updating the same record var car = new Car() { Make = "Yugo", Color = "Brown", CarNickName = "Brownie" }; AddNewRecord(car); var repo1 = new CarRepo(); var car1 = repo1.GetOne(car.CarId); car1.CarNickName = "Updated"; var repo2 = new CarRepo(); var car2 = repo2.GetOne(car.CarId); car2.Make = "Nissan"; repo1.Save(car1); try { repo2.Save(car2); } catch (DbUpdateConcurrencyException ex) { WriteLine(ex); } //RemoveRecordById(car1.CarId, car1.Timestamp); }
static void Main(string[] args) { Console.WriteLine("Hello World from Lesson10_1InterfacesMachineExample!"); //// No interface Example: // CarRepo hummer = new CarRepo(); // hummer.Start(); // hummer.Stop(); // Interface Example: // IMachine hummer = new CarRepo(); // empty constructor with no parameter IMachine hummer = new CarRepo("Yellow H2 Hummer"); ExecuteMachine(hummer); // IMachine honda = new CarRepo(); // empty constructor with no parameter IMachine honda = new CarRepo("White Accord EX Sedan"); // constructor with parameter ExecuteMachine(honda); // IMachine johnDeere = new LawnmowerRepo(); // empty constructor with no parameter IMachine johnDeere = new LawnmowerRepo("Stratton"); ExecuteMachine(johnDeere); }
private void ConfigureGrid() { using (var repo = new CarRepo()) { //Build a LINQ query that gets back some data from the Inventory table gridInventory.ItemsSource = repo.GetAll().Select(x => new { x.CarId, x.Make, x.Color, x.CarNickName }); } }
private static void AddNewRecords(IList <Car> cars) { //Add record to the Inventory table of the AutoLot db using (var repo = new CarRepo()) { repo.AddRange(cars); } }
private static void AddNewRecord(Car car) { //Add record to the Inventory table of the AutoLot db using (var repo = new CarRepo()) { repo.Add(car); } }
private static void PrintAllInventory() { using (var repo = new CarRepo()) { foreach (Car c in repo.GetAll()) { WriteLine(c); } } }
public void MyTestMethod() { CarRepo repo = new CarRepo(); Vehicle car = new Vehicle(); car.Year = 2018; decimal testCost = repo.InsuranceCost(car); decimal actual = testCost; decimal expected = 200m; Assert.AreEqual(actual, expected); }
private static void UpdateRecord(int carId) { using (var repo = new CarRepo()) { //Grab the car, change it, save! var carToUpdate = repo.GetOne(carId); if (carToUpdate != null) { WriteLine("Before change: " + repo.Context.Entry(carToUpdate).State); carToUpdate.Color = "Blue"; WriteLine("After change: " + repo.Context.Entry(carToUpdate).State); repo.Save(carToUpdate); WriteLine("After save: " + repo.Context.Entry(carToUpdate).State); } } }
public CarController() { carRepository = new CarRepo(); }
public Provider() { LocationRepository = new LocationRepo(); CarRepository = new CarRepo(); }