public void RemoveSetOfRegistrationNumber(List <string> RegistrationNumbers) { foreach (var number in RegistrationNumbers) { if (AllCars.Any(x => x.RegistrationNumber == number.ToString())) { this.AllCars.RemoveAll(x => x.RegistrationNumber == number); } } }
public string RemoveCar(string registrationNumber) { if (!AllCars.Any(x => x.RegistrationNumber == registrationNumber)) { return("Car with that registration number, doesn't exist!"); } else { AllCars.Remove(AllCars.Where(x => x.RegistrationNumber == registrationNumber).FirstOrDefault()); return($"Successfully removed {registrationNumber}"); } }
public string AddCar(Car car) { if (AllCars.Any(x => x.RegistrationNumber == car.RegistrationNumber)) { return("Car with that registration number, already exists!"); } if (Count >= Capacity) { return("Parking is full!"); } else { AllCars.Add(car); return($"Successfully added new car {car.Make } {car.RegistrationNumber}"); } }