public static List<Kunde> InitializeKundenListTestData()
        {
            List<Kunde> kundenListTestData = new List<Kunde>();

            Kunde test1 = new Kunde();
            Kunde test2 = new Kunde();
            Kunde test3 = new Kunde();
            Kunde test4 = new Kunde();

            test1.Nachname = "Nass";
            test1.Vorname = "Anna";
            test1.Geburtsdatum = new DateTime(1961, 5, 5);

            test2.Nachname = "Beil";
            test2.Vorname = "Timo";
            test2.Geburtsdatum = new DateTime(1980, 9, 9);

            test3.Nachname = "Pfahl";
            test3.Vorname = "Martha";
            test3.Geburtsdatum = new DateTime(1950, 3, 7);

            test4.Nachname = "Zufall";
            test4.Vorname = "Rainer";
            test4.Geburtsdatum = new DateTime(1944, 11, 11);

            kundenListTestData.Add(test1);
            kundenListTestData.Add(test2);
            kundenListTestData.Add(test3);
            kundenListTestData.Add(test4);
            return kundenListTestData;
        }
 //Kunde Insert(Kunde kunde)
 public Kunde Insert(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         return context.Kunden.Attach(kunde);
     }
 }
 public void CreateKunde(Kunde created)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.AddToKunden(created);
         ctx.SaveChanges();
     }
 }
 public void AddKunde(Kunde kunde)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.AddToKunden(kunde);
         context.SaveChanges();
     }
 }
 public void DeleteKunde(Kunde kunde)
 {
     using (var ctx = new AutoReservationEntities())
     {
         ctx.Kunden.Attach(kunde);
         ctx.Kunden.DeleteObject(kunde);
         ctx.SaveChanges();
     }
 }
 public void DeleteKunde(Kunde kunde)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         context.Kunden.Attach(kunde);
         context.Kunden.DeleteObject(kunde);
         context.SaveChanges();
     }
 }
 //Kunde Delete(Kunde)
 public Kunde Delete(Kunde kunde)
 {
     using (var context = new AutoReservationEntities())
     {
         context.Kunden.Attach(kunde);
         context.Kunden.Remove(kunde);
         return kunde;
     }
 }
        public void Test_InsertKunde()
        {
            int oldCount = Target.LoadKunden().Count;
            Kunde kunde = new Kunde();
            kunde.Nachname = "Holmes";
            kunde.Vorname = "Sherlock";
            kunde.Geburtsdatum = new DateTime(1854, 8, 1);
            Target.InsertKunde(kunde);

            Assert.IsTrue(kunde.Id > 0);

            List<Kunde> kunden = Target.LoadKunden();
            Assert.AreNotEqual(kunden.Count, oldCount);
            Assert.IsNotNull(kunden.Find(k => k.Vorname == "Sherlock" && k.Nachname == "Holmes"));
        }
 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);
         }
     }
 }
 public void Test_UpdateKunde()
 {
     Kunde meinKunde = new Kunde
     {
         Id = 1,
         Vorname = "Zafer",
         Nachname = "Dogan",
         Geburtsdatum = new System.DateTime(1989, 5, 5)
     };
     Kunde meinOriginalKunde = Target.GetKundeById(1);
     Target.UpdateKunde(meinKunde, meinOriginalKunde);
     Kunde meinUpdatedKunde = Target.GetKundeById(1);
     Assert.AreEqual(meinKunde.Vorname, meinUpdatedKunde.Vorname);
     Assert.AreEqual(meinKunde.Nachname, meinUpdatedKunde.Nachname);
     Assert.AreEqual(meinKunde.Geburtsdatum, meinUpdatedKunde.Geburtsdatum);
 }
        //Kunde Update(Kunde modified, Kunde original)
        public Kunde Update(Kunde modified, Kunde original)
        {
            using (var context = new AutoReservationEntities())
            {
                try
                {
                    context.Kunden.Attach(original);
                    context.Entry(original).CurrentValues.SetValues(modified);
                    return modified;
                }
                catch (DbUpdateConcurrencyException e)
                {
                    HandleDbConcurrencyException<Kunde>(context, original);
                    return null;
                }

            }
        }
 public void EditKunde(Kunde kundeOriginal, Kunde kundeModified)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         try
         {
             context.Kunden.Attach(kundeOriginal);
             context.Kunden.ApplyCurrentValues(kundeModified);
             context.SaveChanges();
         }
         catch (OptimisticConcurrencyException ex)
         {
             context.Refresh(System.Data.Objects.RefreshMode.StoreWins, kundeModified);
             throw new LocalOptimisticConcurrencyException<Kunde>(ex.Message);
         }
     }
 }
 public void UpdateKunde(Kunde modified, Kunde original)
 {
     using (var ctx = new AutoReservationEntities())
     {
         try
         {
             ctx.Kunden.Attach(original);
             ctx.Kunden.ApplyCurrentValues(modified);
             ctx.SaveChanges();
         }
         catch (LocalOptimisticConcurrencyException<Kunde>)
         {
             ctx.Refresh(RefreshMode.StoreWins, original);
             ctx.SaveChanges();
         }
     }
 }
 public void UpdateKunde(Kunde modifiedKunde, Kunde originalKunde)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
     {
         try
         {
             context.Kunden.Attach(originalKunde);
             context.Kunden.ApplyCurrentValues(modifiedKunde);
             context.SaveChanges();
         }
         catch (OptimisticConcurrencyException)
         {
             throw new LocalOptimisticConcurrencyException<Kunde>("Kunde wurde bereits verändert.");
         }
     }
 }
 public void UpdateKunde(Kunde modified, Kunde original)
 {
     using (AutoReservationEntities context = new AutoReservationEntities())
      {
          try
          {
              context.Kunden.Attach(original);
              modified.EntityKey = original.EntityKey;
              context.Kunden.ApplyCurrentValues(modified);
              context.SaveChanges();
          }
          catch (OptimisticConcurrencyException e)
          {
              context.Refresh(System.Data.Objects.RefreshMode.StoreWins, modified);
              throw new LocalOptimisticConcurrencyException<Kunde>("update conflict") { Entity = modified };
          }
      }
 }
 /// <summary>
 /// Create a new Kunde object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="nachname">Initial value of the Nachname property.</param>
 /// <param name="vorname">Initial value of the Vorname property.</param>
 /// <param name="geburtsdatum">Initial value of the Geburtsdatum property.</param>
 public static Kunde CreateKunde(global::System.Int32 id, global::System.String nachname, global::System.String vorname, global::System.DateTime geburtsdatum)
 {
     Kunde kunde = new Kunde();
     kunde.Id = id;
     kunde.Nachname = nachname;
     kunde.Vorname = vorname;
     kunde.Geburtsdatum = geburtsdatum;
     return kunde;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Kunden EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToKunden(Kunde kunde)
 {
     base.AddObject("Kunden", kunde);
 }
 public void InsertKundeTest()
 {
     TestEnvironmentHelper.InitializeTestData();
     AutoReservationBusinessComponent autoReservation = new AutoReservationBusinessComponent();
     int count = autoReservation.GetKunden().Count;
     Kunde kunde = new Kunde();
     int id = 99999;
     kunde.Id = id;
     kunde.Nachname = "Nachname";
     kunde.Vorname = "Vorname";
     kunde.Geburtsdatum = System.DateTime.Today;
     autoReservation.InsertKunde(kunde);
     Assert.AreEqual(count + 1, autoReservation.GetKunden().Count);
 }
Example #19
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Kunden EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToKunden(Kunde kunde)
 {
     base.AddObject("Kunden", kunde);
 }
 public void InsertKundeTest()
 {
     Kunde kunde = new Kunde();
     kunde.Geburtsdatum = new DateTime(1900, 10, 10);
     kunde.Nachname = "Bock";
     kunde.Vorname = "Sebastian";
     Kunde resultKunde = Target.addKunde(kunde);
     Assert.AreEqual(5, resultKunde.Id);
     Assert.AreEqual(new DateTime(1900, 10, 10), resultKunde.Geburtsdatum);
     Assert.AreEqual("Bock", resultKunde.Nachname);
     Assert.AreEqual("Sebastian", resultKunde.Vorname);
 }