public void AddCar(Inventory newCar) { Cars.Add(newCar); using (InventoryDal inventory = (new InventoryDal())) { inventory.InsertAuto(ModelTransformations.InventoryToCar(newCar)); } }
public void PersistChanges() { using (InventoryDal inventory = (new InventoryDal())) { foreach (var car in Cars) { if (car.IsChanged) { inventory.UpdateCar(ModelTransformations.InventoryToCar(car)); } } } }