public void AddAuto(Auto auto) { using (AutoReservationEntities context = new AutoReservationEntities()) { context.AddToAutos(auto); context.SaveChanges(); } }
public void CreateAuto(Auto created) { using (var ctx = new AutoReservationEntities()) { ctx.AddToAutos(created); ctx.SaveChanges(); } }
public void DeleteAuto(Auto auto) { using (AutoReservationEntities context = new AutoReservationEntities()) { context.Autos.Attach(auto); context.Autos.DeleteObject(auto); context.SaveChanges(); } }
public void DeleteAuto(Auto auto) { using (var ctx = new AutoReservationEntities()) { ctx.Autos.Attach(auto); ctx.Autos.DeleteObject(auto); ctx.SaveChanges(); } }
public void DeleteAuto(Auto autoDelete) { using (AutoReservationEntities context = new AutoReservationEntities()) { try { context.Autos.Attach(autoDelete); context.DeleteObject(autoDelete); context.SaveChanges(); } catch (OptimisticConcurrencyException ex) { throw new LocalOptimisticConcurrencyException<Auto>(ex.Message); } } }
public void EditAuto(Auto autoOriginal, Auto autoModified) { using (AutoReservationEntities context = new AutoReservationEntities()) { try { context.Autos.Attach(autoOriginal); context.Autos.ApplyCurrentValues(autoModified); context.SaveChanges(); } catch (OptimisticConcurrencyException ex) { Console.WriteLine("AutoReservationBusinessComponent ConcurrencyException"); context.Refresh(System.Data.Objects.RefreshMode.StoreWins, autoModified); throw new LocalOptimisticConcurrencyException<Auto>(ex.Message); } } }
public void UpdateAuto(Auto modifiedAuto, Auto originalAuto) { using (AutoReservationEntities context = new AutoReservationEntities()) { try { context.Autos.Attach(originalAuto); context.Autos.ApplyCurrentValues(modifiedAuto); context.SaveChanges(); } catch (OptimisticConcurrencyException) { throw new LocalOptimisticConcurrencyException<Auto>("Auto wurde bereits verändert."); } } }
public void UpdateAuto(Auto modified, Auto original) { using (AutoReservationEntities context = new AutoReservationEntities()) { try { context.Autos.Attach(original); modified.EntityKey = original.EntityKey; context.Autos.ApplyCurrentValues(modified); context.SaveChanges(); } catch (OptimisticConcurrencyException e) { context.Refresh(System.Data.Objects.RefreshMode.StoreWins, modified); throw new LocalOptimisticConcurrencyException<Auto>("update conflict") { Entity = modified}; } } }
/// <summary> /// Deprecated Method for adding a new object to the Autos EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAutos(Auto auto) { base.AddObject("Autos", auto); }
public void UpdateAuto(Auto modified, Auto original) { using (var ctx = new AutoReservationEntities()) { try { ctx.Autos.Attach(original); ctx.Autos.ApplyCurrentValues(modified); ctx.SaveChanges(); } catch (LocalOptimisticConcurrencyException<Kunde>) { ctx.Refresh(RefreshMode.StoreWins, original); ctx.SaveChanges(); } } }