Ejemplo n.º 1
0
        // Get the cars from the Model
        public void GetCars()
        {
            carManager     = new CarManager();
            _SelectedIndex = -1;

            _Cars.Clear();
            foreach (var car in carManager.Cars)
            {
                var newCar = new CarViewModel(car);
                newCar.PropertyChanged += Car_OnNotifyPropertyChanged;  // Subscribe object to the OnNotifyPropertyChanged Event
                _Cars.Add(newCar);
            }
        }
Ejemplo n.º 2
0
        // Delete Car from list
        public bool Delete(CarViewModel carToDelete)
        {
            bool success = false;

            Debug.WriteLine("CMVM: Delete Car - Starting attempt");

            try
            {
                this.carManager.Delete(carToDelete);
                this._Cars.Remove(carToDelete);
                this._SelectedIndex = -1;
                Debug.WriteLine("CMVM: Delete Car - Successful");
                success = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("CMVM: Delete Car - Failed");
                Debug.WriteLine("Error: " + ex);
            }


            return(success);
        }
Ejemplo n.º 3
0
        public CarViewModel GetCarById(int carId)
        {
            CarViewModel car = this._Cars.Where((x) => x.CarId == carId).FirstOrDefault();

            return(car);
        }