private void Rent_Click(object sender, RoutedEventArgs e)
 {
     if (RentalCardGrid.SelectedItem != null)
     {
         if (rentalCarViewModel.SelectedCar.Available)
         {
             if (user.Balance >= numeric_numOfDays.Value * rentalCarViewModel.SelectedCar.PricePerDay)
             {
                 rentalCarViewModel.SelectedCar.AvailableFrom = DateTime.Now;
                 rentalCarViewModel.SelectedCar.AvailableFrom = rentalCarViewModel.SelectedCar.AvailableFrom.AddDays((int)numeric_numOfDays.Value);
                 rentalCarViewModel.SelectedCar.Available     = false;
                 rentalCarViewModel.SelectedCar.RentedID      = user.ID;
                 user.Pay(rentalCarViewModel.SelectedCar.PricePerDay * numeric_numOfDays.Value);
                 rentalCarViewModel.SerializeCars();
                 user.Serialize();
                 Find_Click(sender, e);
                 ShowMsg("Rental success", "The car is successfully rented");
             }
             else
             {
                 ShowMsg("Rental error", "There are not enough funds on your balance for this rent");
             }
         }
         else
         {
             ShowMsg("Rental error", "The selected car is not available");
             RentalCar.UpdateCarsStatus(this.rentalCarViewModel.Cars.ToList());
         }
     }
     else
     {
         ShowMsg("Rental error", "You have not chosen the car you want to rent");
     }
 }
 public AdminCarsMenu(RentalCarViewModel rentalCarViewModel)
 {
     InitializeComponent();
     this.rentalCarViewModel = rentalCarViewModel;
     this.rentalCarViewModel.DeserializeCars();
     this.rentalCarViewModel.UnfilteredCars();
     RentalCar.UpdateCarsStatus(this.rentalCarViewModel.Cars.ToList());
 }
 public RentCars(RentalCarViewModel rentalCarViewModel, User user)
 {
     InitializeComponent();
     this.rentalCarViewModel = rentalCarViewModel;
     this.rentalCarViewModel.DeserializeCars();
     this.rentalCarViewModel.UnfilteredCars();
     this.user = user;
     RentalCar.UpdateCarsStatus(this.rentalCarViewModel.Cars.ToList());
 }
        private void Find_Click(object sender, RoutedEventArgs e)
        {
            RentalCar.UpdateCarsStatus(this.rentalCarViewModel.Cars.ToList());
            this.rentalCarViewModel.LoadUserRentedCars(this.user.ID);
            rentalCarViewModel.ClearFiltredUserCars();
            if (isAllFiltersUnchecked())
            {
                rentalCarViewModel.UnfilteredUserCars();
            }
            else
            {
                foreach (var car in rentalCarViewModel.UserRentedCars)
                {
                    if (chb_sportCoupe.IsChecked == true && car.Type == chb_sportCoupe.Content.ToString() && !rentalCarViewModel.FiltredUserCars.Contains(car))
                    {
                        rentalCarViewModel.AddUserCarToFiltred(car);
                    }

                    if (chb_suv.IsChecked == true && car.Type == chb_suv.Content.ToString() && !rentalCarViewModel.FiltredUserCars.Contains(car))
                    {
                        rentalCarViewModel.AddUserCarToFiltred(car);
                    }

                    if (chb_stationWagon.IsChecked == true && car.Type == chb_stationWagon.Content.ToString() && !rentalCarViewModel.FiltredUserCars.Contains(car))
                    {
                        rentalCarViewModel.AddUserCarToFiltred(car);
                    }

                    if (chb_minivan.IsChecked == true && car.Type == chb_minivan.Content.ToString() && !rentalCarViewModel.FiltredCars.Contains(car))
                    {
                        rentalCarViewModel.AddUserCarToFiltred(car);
                    }

                    if (chb_electricCar.IsChecked == true && car.Type == chb_electricCar.Content.ToString() && !rentalCarViewModel.FiltredUserCars.Contains(car))
                    {
                        rentalCarViewModel.AddUserCarToFiltred(car);
                    }

                    if (chb_cabriolet.IsChecked == true && car.Type == chb_cabriolet.Content.ToString() && !rentalCarViewModel.FiltredUserCars.Contains(car))
                    {
                        rentalCarViewModel.AddUserCarToFiltred(car);
                    }

                    if (chb_sedan.IsChecked == true && car.Type == chb_sedan.Content.ToString() && !rentalCarViewModel.FiltredUserCars.Contains(car))
                    {
                        rentalCarViewModel.AddUserCarToFiltred(car);
                    }
                }
            }
        }
 public void UpdateCarsStatus()
 {
     RentalCar.UpdateCarsStatus(cars.ToList());
 }