Esempio n. 1
0
        public async Task AddNewSaleAsync(int carID, int customerID, CarSale cars_Sold)
        {
            IndividualCar car = await Context.IndividualCars.Where(ic => ic.Id == carID).SingleAsync();

            Customer customer = await Context.Customers.Where(c => c.Id == customerID).SingleAsync();

            cars_Sold.IndividualCar = car;
            customer.CarSale.Add(cars_Sold);
            await SaveAsync();
        }
Esempio n. 2
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            string validation1 = Validation.ValidEmptyFields(carDetailsGrid);

            if (validation1 != null)
            {
                MessageBox.Show(validation1);
            }
            else
            {
                string validation2 = Validation.ValidEmptyFields(carModelGrid);
                if (validation2 != null)
                {
                    MessageBox.Show(validation2);
                }
                else
                {
                    string validation3 = Validation.ValidEmptyFields(carFeatureGrid);
                    if (validation3 != null)
                    {
                        MessageBox.Show(validation3);
                    }
                    else
                    {
                        CarModel cm = new CarModel();
                        cm.EngineSize    = double.Parse(engineSizeTextBox.Text);
                        cm.Manufacturer  = manufacturerTextBox.Text;
                        cm.Model         = modelTextBox.Text;
                        cm.NumberOfSeats = int.Parse(numberOfSeatsTextBox.Text);

                        IndividualCar ic = new IndividualCar();
                        ic.Body_Type        = body_TypeTextBox.Text;
                        ic.Colour           = colourTextBox.Text;
                        ic.Current_Mileage  = current_MileageTextBox.Text;
                        ic.Date_Imported    = date_ImportedTextBox.Text;
                        ic.Manufacture_Year = int.Parse(manufacture_YearTextBox.Text);
                        ic.Status           = statusTextBox.Text;
                        ic.Transmission     = transmissionTextBox.Text;

                        CarFeature cf = new CarFeature();
                        cf.Car_Feature_Description = car_Feature_DescriptionTextBox.Text;
                        DataStore.addNewCarDetails(cf, cm, ic);
                        MessageBox.Show("Car added successfully");
                    }
                }
            }
            body_TypeTextBox.Clear(); colourTextBox.Clear();
            current_MileageTextBox.Clear(); date_ImportedTextBox.Clear();
            manufacturerTextBox.Clear(); manufacture_YearTextBox.Clear();
            statusTextBox.Clear(); transmissionTextBox.Clear();
            engineSizeTextBox.Clear(); modelTextBox.Clear();
            numberOfSeatsTextBox.Clear();
        }
Esempio n. 3
0
 private void InitializeCar(IndividualCar car)
 {
     Car = new CarWrapper(car);
     Car.PropertyChanged += (s, e) =>
     {
         if (!HasChanges)
         {
             HasChanges = _carRepository.HasChanges();
         }
         ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
     };
     ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
 }
Esempio n. 4
0
        private IndividualCar CreateNewCar()
        {
            var car = new IndividualCar {
                CarModel     = new CarModel(),
                CarSale      = null,
                CarFeatures  = new Collection <CarFeature>(),
                DateImported = DateTime.Now,
                Status       = Constants.CAR_AVAILABLE
            };

            _carRepository.Add(car);
            _carRepository.AddCarModel(car.CarModel);
            return(car);
        }
Esempio n. 5
0
        private void submitCar_Click(object sender, RoutedEventArgs e)
        {
            if (Utility.validEmptyFields(grid1))
            {
                IndividualCar car = new IndividualCar
                {
                    Body_Type        = body_TypeTextBox.Text,
                    Colour           = colourTextBox.Text,
                    Current_Mileage  = current_MileageTextBox.Text,
                    Date_Imported    = date_ImportedTextBox.Text,
                    Manufacture_Year = Convert.ToInt16(manufacture_YearTextBox.Text),
                    //CarID = Convert.ToInt16(carIDTextBox.Text),
                    Model_ID     = Convert.ToInt16(model_IDTextBox.Text),
                    Status       = statusTextBox.Text,
                    Transmission = transmissionTextBox.Text
                };
                var resp = DataStore.AddObject(car, "IndividualCars");

                if (resp.Item1)
                {
                    MessageBox.Show("Successfully Added New Car");
                }
                else
                if (!resp.Item2.Contains("CarModel"))
                {
                    MessageBox.Show("Something went wrong please try again later.", resp.Item2);
                }
                else
                {
                    MessageBox.Show("Please Add a model before adding the Cars for it.", resp.Item2);
                    AddModel main = new AddModel();
                    main.Show();
                    this.Close();
                }
            }
        }
Esempio n. 6
0
 public CarListItemViewModel(IndividualCar car, IEventAggregator eventAggregator)
 {
     Car = car;
     _eventAggregator         = eventAggregator;
     OpenCarDetailViewCommand = new DelegateCommand(OpenCarDetailViewExecute);
 }