//Reservation Insert(Reservation reservation)
 public Reservation Insert(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Reservationen.Attach(reservation);
     }
 }
 public void AddResevation(Reservation reservation)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.AddToReservationen(reservation);
         context.SaveChanges();
     }
 }
 public void CreateReservation(Reservation created)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.AddToReservationen(created);
         ctx.SaveChanges();
     }
 }
 public void DeleteReservation(Reservation reservation)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Reservationen.Attach(reservation);
         context.Reservationen.DeleteObject(reservation);
         context.SaveChanges();
     }
 }
 //Reservation Delete(Reservation reservation)
 public Reservation Delete(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Reservationen.Attach(reservation);
         context.Reservationen.Remove(reservation);
         return reservation;
     }
 }
 public void DeleteReservation(Reservation res)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.Reservationen.Attach(res);
         ctx.Reservationen.DeleteObject(res);
         ctx.SaveChanges();
     }
 }
        public static List<Reservation> InitializeReservationTestData()
        {
            List<Reservation> reservationListTestData = new List<Reservation>();
            Reservation test1 = new Reservation();

            test1.Von = new DateTime(2020, 1, 10);
            test1.Bis = new DateTime(2020, 1, 20);

            reservationListTestData.Add(test1);
            return reservationListTestData;
        }
 public void DeleteReservation(Reservation reservationDelete)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         try
         {
             context.Reservationen.Attach(reservationDelete);
             context.DeleteObject(reservationDelete);
             context.SaveChanges();
         }
         catch (OptimisticConcurrencyException ex)
         {
             throw new LocalOptimisticConcurrencyException<Reservation>(ex.Message);
         }
     }
 }
        //Reservation Update(Reservation modified, Reservation original)
        public Reservation Update(Reservation modified, Reservation original)
        {
            using (var context = new AutoReservationEntities())
            {
                try
                {
                    context.Reservationen.Attach(original);
                    context.Entry(original).CurrentValues.SetValues(modified);
                    return modified;
                }

                catch (DbUpdateConcurrencyException e)
                {
                    HandleDbConcurrencyException<Reservation>(context, original);
                    return null;
                }
            }
        }
 public void EditReservation(Reservation reservationOriginal, Reservation reservationModified)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         try
         {
             context.Reservationen.Attach(reservationOriginal);
             context.Reservationen.ApplyCurrentValues(reservationModified);
             context.SaveChanges();
         }
         catch (OptimisticConcurrencyException ex)
         {
             Console.WriteLine("AutoReservationBusinessComponent ConcurrencyException");
             //context.AcceptAllChanges();
             context.Refresh(System.Data.Objects.RefreshMode.StoreWins, reservationModified);
             throw new LocalOptimisticConcurrencyException<Reservation>(ex.Message);
         }
     }
 }
 public void UpdateReservation(Reservation modifiedReservation, Reservation originalReservation)
 {
     try
     {
         using (AutoReservationEntities context = new AutoReservationEntities())
         {
             context.Reservationen.Attach(originalReservation);
             context.Reservationen.ApplyCurrentValues(modifiedReservation);
             context.SaveChanges();
         }
     }
     catch (OptimisticConcurrencyException)
     {
         throw new LocalOptimisticConcurrencyException<Reservation>("Reservation wurde bereits verändert.");
     }
 }
 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 };
         }
      }
 }
 /// <summary>
 /// Create a new Reservation object.
 /// </summary>
 /// <param name="reservationNr">Initial value of the ReservationNr property.</param>
 /// <param name="autoId">Initial value of the AutoId property.</param>
 /// <param name="kundeId">Initial value of the KundeId property.</param>
 /// <param name="von">Initial value of the Von property.</param>
 /// <param name="bis">Initial value of the Bis property.</param>
 public static Reservation CreateReservation(global::System.Int32 reservationNr, global::System.Int32 autoId, global::System.Int32 kundeId, global::System.DateTime von, global::System.DateTime bis)
 {
     Reservation reservation = new Reservation();
     reservation.ReservationNr = reservationNr;
     reservation.AutoId = autoId;
     reservation.KundeId = kundeId;
     reservation.Von = von;
     reservation.Bis = bis;
     return reservation;
 }
Пример #14
0
 public void Test_UpdateReservation()
 {
     Auto meinAuto = Target.GetAutoById(2);
     Kunde meinKunde = Target.GetKundeById(1);
     Reservation meinReservation = new Reservation
     {
         Auto = meinAuto,
         AutoId = 2,
         Kunde = meinKunde,
         KundeId = 1,
         ReservationNr = 1,
         Von = new System.DateTime(1960, 2, 2),
         Bis = new System.DateTime(1960, 2, 5)
     };
     Reservation meinOriginalReservation = Target.GetReservationByNr(1);
     Target.UpdateReservation(meinReservation, meinOriginalReservation);
     Reservation meinInsertedReservation = Target.GetReservationByNr(1);
     Assert.AreEqual(meinReservation.Auto.Marke, meinInsertedReservation.Auto.Marke);
     Assert.AreEqual(meinReservation.Auto.Tagestarif, meinInsertedReservation.Auto.Tagestarif);
     Assert.AreEqual(meinReservation.AutoId, meinInsertedReservation.AutoId);
     Assert.AreEqual(meinReservation.Von, meinInsertedReservation.Von);
     Assert.AreEqual(meinReservation.Bis, meinInsertedReservation.Bis);
 }
 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();
         }
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Reservationen EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToReservationen(Reservation reservation)
 {
     base.AddObject("Reservationen", reservation);
 }
Пример #17
0
        public void Test_InsertReservation()
        {
            List<Auto> autos = Target.LoadAutos();
            List<Kunde> kunden = Target.LoadKunden();

            if (autos.Count > 0 && kunden.Count > 0)
            {
                Reservation res = new Reservation();
                res.KundeId = kunden[0].Id;
                res.AutoId = autos[0].Id;
                res.Von = new DateTime(2015, 11, 30);
                res.Bis = new DateTime(2015, 12, 13);
                Target.InsertReservation(res);

                Assert.IsTrue(res.ReservationNr > 0);
            }
            else
            {
                Assert.Inconclusive("Cannot run test, since there are no cars or customers available.");
            }
        }
 public void InsertReservationTest()
 {
     Reservation reservation = new Reservation();
     reservation.Von = new DateTime(1900, 10, 10);
     reservation.Bis = new DateTime(1980, 10, 10);
     Kunde kunde = Target.getKunde(3);
     reservation.KundeId = kunde.Id;
     Auto auto = Target.getAuto(2);
     reservation.AutoId = auto.Id;
     Reservation resultReservation = Target.addReservation(reservation);
     Assert.AreEqual(4, resultReservation.ReservationsNr);
     Assert.AreEqual(new DateTime(1900, 10, 10), resultReservation.Von);
     Assert.AreEqual(new DateTime(1980, 10, 10), resultReservation.Bis);
     Assert.AreEqual(3, resultReservation.Kunde.Id);
     Assert.AreEqual(2, resultReservation.Auto.Id);
 }