Exemple #1
0
 public void Add(T entity)
 {
     var ctx = new InventarisierungsloesungDB();
     {
         try
         {
             ctx.Set <T>().Add(entity);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             MessageBox.Show("Es konnte keine Verbindung zur Datenbank hergestellt werden: " + e.Message);
         }
     }
 }
 public override void Update(customer entity)
 {
     var ctx = new InventarisierungsloesungDB();
     {
         try
         {
             var toUpdate = ctx.customers.Find(entity.customer_id);
             ctx.customers.Attach(toUpdate);
             ctx.SaveChanges();
         }
         catch (Exception e)
         {
             MessageBox.Show("Es konnte keine Verbindung zur Datenbank hergestellt werden: " + e.Message);
         }
     }
 }
        public override void Delete(location entity)
        {
            var ctx = new InventarisierungsloesungDB();

            {
                try
                {
                    var toDelete = ctx.locations.Find(entity.location_id);
                    ctx.locations.Remove(toDelete);
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Es konnte keine Verbindung zur Datenbank hergestellt werden: " + e.Message);
                }
            }
            ctx.Dispose();
        }