Exemplo n.º 1
0
        private static void HandleDbConcurrencyException <T>(AutoReservationEntities context, T original) where T : class
        {
            var databaseValue = context.Entry(original).GetDatabaseValues();

            context.Entry(original).CurrentValues.SetValues(databaseValue);

            throw new LocalOptimisticConcurrencyException <T>($"Update {typeof (T).Name}: Concurrency-Fehler", original);
        }
Exemplo n.º 2
0
 public void UpdateKunde(Kunde modified, Kunde original)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         try
         {
             context.Kunde.Attach(original);
             context.Entry(original).CurrentValues.SetValues(modified);
             context.SaveChanges();
         }
         catch (DbUpdateConcurrencyException e)
         {
             HandleDbConcurrencyException(context, original);
         }
     }
 }
Exemplo n.º 3
0
 public virtual void UpdateReservation(Reservation original, Reservation modified)
 {
     using (var context = new AutoReservationEntities())
     {
         try
         {
             context.Reservationen.Attach(original);
             context.Entry(original).CurrentValues.SetValues(modified);
             context.SaveChanges();
         }
         catch (DbUpdateConcurrencyException)
         {
             HandleDbConcurrencyException(context, original);
         }
     }
 }
 //Kunde Update(Kunde modified, Kunde original)
 public Kunde Update(Kunde modified, Kunde original)
 {
     using (var context = new AutoReservationEntities())
     {
         try
         {
             context.Kunden.Attach(original);
             context.Entry(original).CurrentValues.SetValues(modified);
             return(modified);
         }
         catch (DbUpdateConcurrencyException e)
         {
             HandleDbConcurrencyException <Kunde>(context, original);
             return(null);
         }
     }
 }
Exemplo n.º 5
0
 public Reservation UpdateReservation(Reservation modified, Reservation original)
 {
     using (var context = new AutoReservationEntities())
     {
         try {
             context.Reservationen.Attach(original);
             context.Entry(original).CurrentValues.SetValues(modified);
             context.SaveChanges();
             return(modified);
         }
         catch (DbUpdateConcurrencyException e)
         {
             HandleDbConcurrencyException <Reservation>(context, original);
             return(null);
         }
     }
 }
Exemplo n.º 6
0
 public Auto UpdateAuto(Auto modified, Auto original)
 {
     using (var context = new AutoReservationEntities())
     {
         try
         {
             context.Autos.Attach(original);
             context.Entry(original).CurrentValues.SetValues(modified);
             context.SaveChanges();
             return(modified);
         }
         catch (DbUpdateConcurrencyException e)
         {
             HandleDbConcurrencyException <Auto>(context, original);
             return(null);
         }
     }
 }
        public void UpdateAuto(Auto original, Auto modified)
        {
            context.Autos.Attach(original);
            context.Entry(original).CurrentValues.SetValues(modified);

            try
            {
                context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                HandleDbConcurrencyException(context, original);
            }
            context.Entry(original).State = EntityState.Detached;
        }