Example #1
0
 public Auto Delete(Auto auto)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         dbContext.Entry(auto).State = EntityState.Deleted;
         dbContext.SaveChanges();
         return(auto);
     }
 }
Example #2
0
 public Kunde Delete(Kunde kunde)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         dbContext.Entry(kunde).State = EntityState.Deleted;
         dbContext.SaveChanges();
         return(kunde);
     }
 }
Example #3
0
 public Reservation Delete(Reservation res)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         dbContext.Entry(res).State = EntityState.Deleted;
         dbContext.SaveChanges();
         return(res);
     }
 }
Example #4
0
        protected static OptimisticConcurrencyException <T> CreateOptimisticConcurrencyException <T>(KundenReservationContext context, T entity)
            where T : class
        {
            var dbEntity = (T)context.Entry(entity)
                           .GetDatabaseValues()
                           .ToObject();

            return(new OptimisticConcurrencyException <T>($"Update {typeof(T).Name}: Concurrency-Fehler", dbEntity));
        }
Example #5
0
 public Kunde Insert(Kunde kunde)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         Kunde insertedKunde = dbContext.Kunden.Add(kunde);
         dbContext.Entry(insertedKunde).State = EntityState.Added;
         dbContext.SaveChanges();
         return(insertedKunde);
     }
 }
Example #6
0
 public Auto Insert(Auto auto)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         Auto insertedAuto = dbContext.Autos.Add(auto);
         dbContext.Entry(insertedAuto).State = EntityState.Added;
         dbContext.SaveChanges();
         return(insertedAuto);
     }
 }
Example #7
0
 public Reservation Insert(Reservation res)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         Reservation insertedReservation = dbContext.Reservationen.Add(res);
         dbContext.Entry(insertedReservation).State = EntityState.Added;
         dbContext.SaveChanges();
         return(insertedReservation);
     }
 }
Example #8
0
 public Kunde Update(Kunde kunde)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         try
         {
             dbContext.Entry(kunde).State = EntityState.Modified;
             dbContext.SaveChanges();
             return(kunde);
         }
         catch (DbUpdateConcurrencyException ex)
         {
             throw ManagerBase.CreateOptimisticConcurrencyException <Kunde>(dbContext, kunde);
         }
     }
 }
Example #9
0
 public Auto Update(Auto auto)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         try
         {
             dbContext.Entry(auto).State = EntityState.Modified;
             dbContext.SaveChanges();
             return(auto);
         }
         catch (DbUpdateConcurrencyException ex)
         {
             throw CreateOptimisticConcurrencyException <Auto>(dbContext, auto);
         }
     }
 }
Example #10
0
 public Reservation Update(Reservation res)
 {
     using (KundenReservationContext dbContext = new KundenReservationContext())
     {
         try
         {
             dbContext.Entry(res).State = EntityState.Modified;
             dbContext.SaveChanges();
             return(res);
         }
         catch (DbUpdateConcurrencyException)
         {
             throw CreateOptimisticConcurrencyException <Reservation>(dbContext, res);
         }
     }
 }