public Auto Delete(Auto auto) { using (KundenReservationContext dbContext = new KundenReservationContext()) { dbContext.Entry(auto).State = EntityState.Deleted; dbContext.SaveChanges(); return(auto); } }
public Kunde Delete(Kunde kunde) { using (KundenReservationContext dbContext = new KundenReservationContext()) { dbContext.Entry(kunde).State = EntityState.Deleted; dbContext.SaveChanges(); return(kunde); } }
public Reservation Delete(Reservation res) { using (KundenReservationContext dbContext = new KundenReservationContext()) { dbContext.Entry(res).State = EntityState.Deleted; dbContext.SaveChanges(); return(res); } }
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)); }
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); } }
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); } }
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); } }
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); } } }
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); } } }
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); } } }