Exemplo n.º 1
0
        private void UpdateCar()
        {
            CarViewModel car = lBox.SelectedItem as CarViewModel;

            if (car != null)
            {
                EditCarWindow ecw = new EditCarWindow(car, true);
                ecw.Title = "Редактировать " + car.CarId + " - " + car.Brand;
                var result = ecw.ShowDialog();
                if (result == true)
                {
                    sellerService.UpdateCar(car);
                    ecw.Close();

                    var seller = (SellerViewModel)cBoxGroup.SelectedItem;
                    int sIndex = sellers.IndexOf(seller);
                    int cIndex = seller.Cars.IndexOf(car);

                    ResetCollection();
                    cBoxGroup.SelectedIndex = sIndex;
                    lBox.SelectedIndex      = cIndex;
                }
            }
            else
            {
                MessageBox.Show("Выберите автомобиль для редактирования", "Ошибка получения индекса", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 2
0
        private void AddCar()
        {
            var car    = new CarViewModel();
            var dialog = new EditCarWindow(car, false);
            var result = dialog.ShowDialog();

            if (result == true)
            {
                var seller = (SellerViewModel)cBoxGroup.SelectedItem;
                int sIndex = sellers.IndexOf(seller);
                sellerService.AddCarToSeller(seller.SellerId, car);
                dialog.Close();
                ResetCollection();

                cBoxGroup.SelectedIndex = sIndex;
                lBox.SelectedIndex      = seller.Cars.IndexOf(seller.Cars.Last());
            }
        }