//Reservation Insert(Reservation reservation)
 public Reservation Insert(Reservation reservation)
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Reservationen.Attach(reservation);
     }
 }
コード例 #2
0
        public void UpdateAutoTest()
        {
            using (AutoReservationEntities context = new AutoReservationEntities())
            {
                TestEnvironmentHelper.InitializeTestData();
                AutoReservationBusinessComponent arbc = new AutoReservationBusinessComponent();

                var res = (from auto in context.Autos select auto).FirstOrDefault().Id;
                //Console.WriteLine("Abgefragte Id:" + res);

                Auto autoOriginal = arbc.GetAuto(res);
                Auto autoModified = arbc.GetAuto(res);
                //Console.WriteLine("Marke original vorher:" + autoOriginal.Marke);
                //Console.WriteLine("Marke modified vorher:" + autoModified.Marke);

                autoModified.Marke = "Fiat Punto Abart";
                arbc.EditAuto(autoOriginal, autoModified);

                //Auto autoControl = arbc.GetAuto(res);
                //Console.WriteLine("Marke original nachher:" + autoOriginal.Marke);
                //Console.WriteLine("Marke control  nachher:" + autoControl.Marke);
                //Console.WriteLine("Marke modified nachher:" + autoModified.Marke);

                Assert.AreEqual(autoOriginal.Marke, autoModified.Marke, "UpdateAutoTest: Autos sind nicht gleich nach Update");
            }
        }
コード例 #3
0
 //Auto Get(Id)
 public Kunde GetKunde(int id)
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Kunden.Find(id);
     }
 }
コード例 #4
0
        public static void InitializeTestData()
        {
            using (AutoReservationEntities context = new AutoReservationEntities())
            {
                var connection = (SqlConnection)context.Database.Connection;
                var command = new SqlCommand();
                command.Connection = connection;

                connection.Open();

                DeleteAll(command);

                // Insert Autos
                SetAutoIncrementOnTable(connection, "Auto", true);
                InsertAutos(command);
                SetAutoIncrementOnTable(connection, "Auto", false);

                // Insert Kunden
                SetAutoIncrementOnTable(connection, "Kunde", true);
                InsertKunden(command);
                SetAutoIncrementOnTable(connection, "Kunde", false);

                // Insert Reservationen
                SetAutoIncrementOnTable(connection, "Reservation", true);
                InsertReservationen(command);
                SetAutoIncrementOnTable(connection, "Reservation", false);
            }
        }
コード例 #5
0
 //Kunde Insert(Kunde kunde)
 public Kunde Insert(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Kunden.Attach(kunde);
     }
 }
コード例 #6
0
 public List<Auto> GetAutos()
 {
     using (var ctx = new AutoReservationEntities())
     {
         return ctx.Autos.ToList<Auto>();
     }
 }
 //Reservation Get(Id)
 public Reservation GetReservation(int id)
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Reservationen.Include("Auto").Include("Kunde").ToList().Find(i => i.ReservationNr == id);
     }
 }
 //Reservation
 //List<Reservation> GetAll()
 public List<Reservation> GetReservationen()
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Reservationen.Include("Auto").Include("Kunde").ToList();
     }
 }
コード例 #9
0
 //Kunde
 //List<Kunde> GetAll()
 public List<Kunde> GetKunden()
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Kunden.ToList();
     }
 }
コード例 #10
0
 public void CreateAuto(Auto created)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.AddToAutos(created);
         ctx.SaveChanges();
     }
 }
コード例 #11
0
 public void CreateReservation(Reservation created)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.AddToReservationen(created);
         ctx.SaveChanges();
     }
 }
コード例 #12
0
 public void AddKunde(Kunde kunde)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.AddToKunden(kunde);
         context.SaveChanges();
     }
 }
コード例 #13
0
 public void AddAuto(Auto auto)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.AddToAutos(auto);
         context.SaveChanges();
     }
 }
コード例 #14
0
 public void CreateKunde(Kunde created)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.AddToKunden(created);
         ctx.SaveChanges();
     }
 }
コード例 #15
0
 public void AddResevation(Reservation reservation)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.AddToReservationen(reservation);
         context.SaveChanges();
     }
 }
コード例 #16
0
 public void DeleteAuto(Auto auto)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Autos.Attach(auto);
         context.Autos.DeleteObject(auto);
         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;
     }
 }
コード例 #18
0
 public void DeleteAuto(Auto auto)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.Autos.Attach(auto);
         ctx.Autos.DeleteObject(auto);
         ctx.SaveChanges();
     }
 }
コード例 #19
0
 public void DeleteKunde(Kunde kunde)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.Kunden.Attach(kunde);
         ctx.Kunden.DeleteObject(kunde);
         ctx.SaveChanges();
     }
 }
コード例 #20
0
 public void DeleteReservation(Reservation res)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.Reservationen.Attach(res);
         ctx.Reservationen.DeleteObject(res);
         ctx.SaveChanges();
     }
 }
コード例 #21
0
 public void DeleteKunde(Kunde kunde)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Kunden.Attach(kunde);
         context.Kunden.DeleteObject(kunde);
         context.SaveChanges();
     }
 }
コード例 #22
0
 public void DeleteReservation(Reservation reservation)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Reservationen.Attach(reservation);
         context.Reservationen.DeleteObject(reservation);
         context.SaveChanges();
       }
 }
コード例 #23
0
 //Kunde Delete(Kunde)
 public Kunde Delete(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Kunden.Attach(kunde);
         context.Kunden.Remove(kunde);
         return kunde;
     }
 }
コード例 #24
0
 public Auto GetAuto(int autoId)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         var auto = from r in context.Autos
                     where r.Id == autoId
                     select r;
         return auto.FirstOrDefault();
      }
 }
コード例 #25
0
        public List<Kunde> GetKunden()
        {
            using (AutoReservationEntities context = new AutoReservationEntities())
            {
                var kunden = from k in context.Kunden
                             select k;

                return kunden.ToList();
             }
        }
コード例 #26
0
        public List<Auto> GetAutos()
        {
            using (AutoReservationEntities context = new AutoReservationEntities())
            {
                var autos = from a in context.Autos
                            select a;

                return autos.ToList();
             }
        }
コード例 #27
0
 public Kunde GetKunde(int kundenId)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         var kunde = from r in context.Kunden
                           where r.Id == kundenId
                           select r;
         return kunde.FirstOrDefault();
      }
 }
コード例 #28
0
 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);
         }
     }
 }
コード例 #29
0
 public void DeleteKunde(Kunde kundeDelete)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         try
         {
             context.Kunden.Attach(kundeDelete);
             context.DeleteObject(kundeDelete);
             context.SaveChanges();
         }
         catch (OptimisticConcurrencyException ex)
         {
             throw new LocalOptimisticConcurrencyException<Kunde>(ex.Message);
         }
     }
 }
コード例 #30
0
 public void DeleteAuto(Auto autoDelete)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         try
         {
             context.Autos.Attach(autoDelete);
             context.DeleteObject(autoDelete);
             context.SaveChanges();
         }
         catch (OptimisticConcurrencyException ex)
         {
             throw new LocalOptimisticConcurrencyException<Auto>(ex.Message);
         }
     }
 }