private void OnAddCarExecute() { var carToAdd = SelectedAvailableCar; Rent.ClassModel.Cars.Add(carToAdd); AddedCars.Add(carToAdd); AvailableCars.Remove(carToAdd); HasChanges = this.rentRepository.HasChanges(); ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged(); }
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}"); } }