private void Wyswietl()
 {
     using (var context = new ControlTowerContext())
     {
         var query =
             from products in context.AirCrafts
             orderby products.AirCraftId
             select products;
         datagridSamoloty.ItemsSource = query.ToList();
     };
 }
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (btEdit == true)
            {
                using (var context = new ControlTowerContext())
                {
                    int    id    = Int32.Parse(txtboxId.Text);
                    string model = txtboxModel.Text;
                    string linia = txtboxLinia.Text;

                    var query =
                        from products in context.AirCrafts
                        where products.AirCraftId == id
                        select products;
                    foreach (Models.AirCraft prod in query)
                    {
                        prod.NameAirLine = linia;
                        prod.NameModel   = model;
                        //prod.Nazwa = nazwa;
                    }
                    ;
                    context.SaveChanges();
                    Wyswietl();
                }
            }
            else if (btAdd == true)
            {
                using (var context = new ControlTowerContext())
                {
                    string model = txtboxModel.Text;
                    string linia = txtboxLinia.Text;
                    context.AirCrafts.Add(new Models.AirCraft()
                    {
                        NameModel = model, NameAirLine = linia
                    });
                    context.SaveChanges();
                };
                Wyswietl();
            }
            else if (btDelet == true)
            {
                using (var context = new ControlTowerContext())
                {
                    int id = Int32.Parse(txtboxId.Text);
                    //string model = txtboxModel.Text;
                    //string linia = txtboxLinia.Text;

                    var query =
                        from products in context.AirCrafts
                        where products.AirCraftId == id
                        select products;
                    foreach (var proc in query)
                    {
                        context.AirCrafts.Remove(proc);
                        //prod.Nazwa = nazwa;
                    }
                    ;
                    context.SaveChanges();
                    Wyswietl();
                }
            }
        }