Exemplo n.º 1
0
        private void DeleteCatButton_Click(object sender, RoutedEventArgs e)
        {
            using (CarentContext db = new CarentContext())
            {
                Car car = db.Cars.Find(CurrentId);
                db.Cars.Remove(car);
                db.SaveChanges();
            }
            AdminCars ac = new AdminCars();

            NavigationService.Navigate(ac);
        }
Exemplo n.º 2
0
        private void EditCarButton_Click(object sender, RoutedEventArgs e)
        {
            using (CarentContext db = new CarentContext())
            {
                Car car = db.Cars.Find(CurrentId);
                car.Automaker      = AutomakerTextBox.Text;
                car.Model          = ModelTextBox.Text;
                car.Price          = int.Parse(PriceTextBox.Text);
                car.Year           = int.Parse(YearTextBox.Text);
                car.Transmission   = TransmissionTextBox.Text;
                car.EngineCapacity = int.Parse(EngineCapacityTextBox.Text);
                car.Consumption    = ConsumptionTextBox.Text;
                car.Image          = ImageTextBox.Text;
                db.SaveChanges();
            }
            AdminCars ac = new AdminCars();

            NavigationService.Navigate(ac);
        }
Exemplo n.º 3
0
        private void AddCarButton_Click(object sender, RoutedEventArgs e)
        {
            using (CarentContext db = new CarentContext())
            {
                Car car = new Car()
                {
                    Automaker      = AutomakerTextBox.Text,
                    Model          = ModelTextBox.Text,
                    Price          = int.Parse(PriceTextBox.Text),
                    Year           = int.Parse(YearTextBox.Text),
                    Transmission   = TransmissionTextBox.Text,
                    EngineCapacity = int.Parse(EngineCapacityTextBox.Text),
                    Consumption    = ConsumptionTextBox.Text,
                    Image          = ImageTextBox.Text,
                    Class          = ClassTextBox.Text
                };
                db.Cars.Add(car);
                db.SaveChanges();
            }
            AdminCars ac = new AdminCars();

            NavigationService.Navigate(ac);
        }
Exemplo n.º 4
0
        private void AdminCars_Click(object sender, RoutedEventArgs e)
        {
            AdminCars ac = new AdminCars();

            NavigationService.Navigate(ac);
        }