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 UpdateReservation(Reservation modified, Reservation original) { using (AutoReservationEntities context = new AutoReservationEntities()) { try { context.Reservationen.Attach(original); modified.EntityKey = original.EntityKey; context.Reservationen.ApplyCurrentValues(modified); context.SaveChanges(); } catch (OptimisticConcurrencyException e) { context.Refresh(System.Data.Objects.RefreshMode.StoreWins, modified); throw new LocalOptimisticConcurrencyException<Reservation>("update conflict") { Entity = modified }; } } }
public void EditKunde(Kunde kundeOriginal, Kunde kundeModified) { using (AutoReservationEntities context = new AutoReservationEntities()) { try { context.Kunden.Attach(kundeOriginal); context.Kunden.ApplyCurrentValues(kundeModified); context.SaveChanges(); } catch (OptimisticConcurrencyException ex) { context.Refresh(System.Data.Objects.RefreshMode.StoreWins, kundeModified); throw new LocalOptimisticConcurrencyException<Kunde>(ex.Message); } } }
public void UpdateReservation(Reservation modified, Reservation original) { using (var ctx = new AutoReservationEntities()) { try { ctx.Reservationen.Attach(original); ctx.Reservationen.ApplyCurrentValues(modified); ctx.SaveChanges(); } catch (LocalOptimisticConcurrencyException<Kunde>) { ctx.Refresh(RefreshMode.StoreWins, original); ctx.SaveChanges(); } } }