Exemple #1
0
        public void UpdateAuto(Auto modified, Auto original)
        {
            using (var context = new AutoReservationEntities())
            {
                try
                {
                    context.Autos.Attach(original);
                    context.Autos.ApplyCurrentValues(modified);
                    context.SaveChanges();
                }
                catch (OptimisticConcurrencyException)
                {
                    modified.EntityKey = original.EntityKey;

                    context.Refresh(RefreshMode.StoreWins, modified);
                    context.SaveChanges();

                    throw new LocalOptimisticConcurrencyException <Auto>(
                              "Konflikt beim Ändern eines Wertes der Klasse Auto")
                          {
                              Entity = modified
                          };
                }
            }
        }
Exemple #2
0
 public void CreateAuto(Auto auto)
 {
     using (var context = new AutoReservationEntities()){
         context.AddToAutos(auto);
         context.SaveChanges();
     }
 }
Exemple #3
0
 public void AddKunde(Kunde kunde)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Kunde.Add(kunde);
         context.SaveChanges();
     }
 }
Exemple #4
0
 public void CreateKunde(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         context.AddToKunden(kunde);
         context.SaveChanges();
     }
 }
Exemple #5
0
 public void AddAuto(Auto auto)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Auto.Add(auto);
         context.SaveChanges();
     }
 }
Exemple #6
0
 public void AddReserveration(Reservation reservation)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Reservation.Add(reservation);
         context.SaveChanges();
     }
 }
Exemple #7
0
 public void CreateReservation(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         context.AddToReservationen(reservation);
         context.SaveChanges();
     }
 }
Exemple #8
0
 public void DeleteReservation(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Reservationen.Attach(reservation);
         context.Reservationen.DeleteObject(reservation);
         context.SaveChanges();
     }
 }
Exemple #9
0
 public void DeleteKunde(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Kunden.Attach(kunde);
         context.Kunden.DeleteObject(kunde);
         context.SaveChanges();
     }
 }
Exemple #10
0
 public int InsertReservation(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         context.AddToReservationen(reservation);
         context.SaveChanges();
         return(reservation.ReservationNr);
     }
 }
Exemple #11
0
 public int InsertKunde(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         context.AddToKunden(kunde);
         context.SaveChanges();
         return(kunde.Id);
     }
 }
Exemple #12
0
 public int InsertAuto(Auto auto)
 {
     using (var context = new AutoReservationEntities())
     {
         context.AddToAutos(auto);
         context.SaveChanges();
         return(auto.Id);
     }
 }
Exemple #13
0
 public void DeleteAuto(Auto auto)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Auto.Attach(auto);
         context.Auto.Remove(auto);
         context.SaveChanges();
     }
 }
Exemple #14
0
 public Kunde InsertKunde(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         var newKunde = context.Kunden.Add(kunde);
         context.SaveChanges();
         return(newKunde);
     }
 }
Exemple #15
0
 public Reservation InsertReservation(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         var newReservation = context.Reservationen.Add(reservation);
         context.SaveChanges();
         return(newReservation);
     }
 }
Exemple #16
0
 public void DeleteKunde(Kunde kunde)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Kunde.Attach(kunde);
         context.Kunde.Remove(kunde);
         context.SaveChanges();
     }
 }
Exemple #17
0
 public Auto InsertAuto(Auto auto)
 {
     using (var context = new AutoReservationEntities())
     {
         var newAuto = context.Autos.Add(auto);
         context.SaveChanges();
         return(newAuto);
     }
 }
Exemple #18
0
 public void DeleteReservation(Reservation reservation)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Reservation.Attach(reservation);
         context.Reservation.Remove(reservation);
         context.SaveChanges();
     }
 }
Exemple #19
0
 public void DeleteAuto(Auto auto)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Autos.Attach(auto);
         context.Autos.DeleteObject(auto);
         context.SaveChanges();
     }
 }
        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;
        }
Exemple #21
0
 public Auto DeleteAuto(Auto auto)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Autos.Attach(auto);
         var deletedAuto = context.Autos.Remove(auto);
         context.SaveChanges();
         return(deletedAuto);
     }
 }
Exemple #22
0
 public Reservation DeleteReservation(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Reservationen.Attach(reservation);
         var deletedReservation = context.Reservationen.Remove(reservation);
         context.SaveChanges();
         return(deletedReservation);
     }
 }
Exemple #23
0
 public Kunde DeleteKunde(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Kunden.Attach(kunde);
         var deletedKunde = context.Kunden.Remove(kunde);
         context.SaveChanges();
         return(deletedKunde);
     }
 }
Exemple #24
0
        public void UpdateReservation(Reservation modified, Reservation original)
        {
            using (var context = new AutoReservationEntities())
            {
                try
                {
                    context.Reservationen.Attach(original);
                    context.Reservationen.ApplyCurrentValues(modified);
                    context.SaveChanges();
                }
                catch (OptimisticConcurrencyException)
                {
                    modified.EntityKey = original.EntityKey;

                    context.Refresh(RefreshMode.StoreWins, modified);
                    context.SaveChanges();

                    throw new LocalOptimisticConcurrencyException <Reservation>("Update Reservation: Concurrency-Fehler")
                          {
                              Entity = modified
                          };
                }
            }
        }
Exemple #25
0
 public void AddKunden(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         try
         {
             context.Kunden.Add(kunde);
             context.SaveChanges();
         }
         catch (DbUpdateConcurrencyException)
         {
             HandleDbConcurrencyException(context, kunde);
         }
     }
 }
Exemple #26
0
 public void AddReservation(Reservation res)
 {
     using (var context = new AutoReservationEntities())
     {
         try
         {
             context.Reservationen.Add(res);
             context.SaveChanges();
         }
         catch (DbUpdateConcurrencyException)
         {
             HandleDbConcurrencyException(context, res);
         }
     }
 }
Exemple #27
0
 public void AddAuto(Auto auto)
 {
     using (var context = new AutoReservationEntities())
     {
         try
         {
             context.Autos.Add(auto);
             context.SaveChanges();
         }
         catch (DbUpdateConcurrencyException)
         {
             HandleDbConcurrencyException(context, auto);
         }
     }
 }
Exemple #28
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);
         }
     }
 }
Exemple #29
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);
         }
     }
 }
Exemple #30
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);
         }
     }
 }