private void OnAddCarExecute() { var carToAdd = SelectedAvailableCar; Rent.ClassModel.Cars.Add(carToAdd); AddedCars.Add(carToAdd); AvailableCars.Remove(carToAdd); HasChanges = this.rentRepository.HasChanges(); ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); }
public void RemoveSetOfRegistrationNumber(List <string> RegistrationNumbers) { for (int i = 0; i < RegistrationNumbers.Count; i++) { foreach (var car in AddedCars) { if (car.RegistrationNumber == RegistrationNumbers[i]) { AddedCars.Remove(car); } } } }
private void SetupPicklist() { var rentCarIds = Rent.ClassModel.Cars.Select(c => c.Id).ToList(); var addedCars = this.allCars.Where(c => rentCarIds.Contains(c.Id)).OrderBy(c => c.Brand); var availableCars = this.allCars.Except(addedCars).OrderBy(c => c.Brand); AddedCars.Clear(); AvailableCars.Clear(); foreach (var addedCar in addedCars) { AddedCars.Add(addedCar); } foreach (var availableCar in availableCars) { AvailableCars.Add(availableCar); } }
public string AddCar(Car car) { for (int i = 0; i < AddedCars.Count; i++) { if (AddedCars[i].RegistrationNumber == car.RegistrationNumber) { return("Car with that registration number, already exists!"); } } if (AddedCars.Count == capacity) { return("Parking is full!"); } else { AddedCars.Add(car); return($"Successfully added new car {car.Make} {car.RegistrationNumber}"); } }
public string RemoveCar(string RegistrationNumber) { bool carExist = false; for (int i = 0; i < AddedCars.Count; i++) { if (AddedCars[i].RegistrationNumber == RegistrationNumber) { AddedCars.RemoveAt(i); carExist = true; break; } } if (!carExist) { return("Car with that registration number, doesn't exist!"); } else { return($"Successfully removed {RegistrationNumber}"); } }