public bool Remove(Residence residence, Rentals rentals) { // check if still used in rentals: can't remove then! foreach (Rental rental in rentals.AllRentals) { if (rental.HolidayResidence == residence) { return(false); } } return(AllResidences.Remove(residence)); }
public bool DeleteResidence(Residence residence) { Rentals rentals = new Rentals(); foreach (Rental rental in rentals.AllRentals) { if (rental.HolidayResidence == residence) { return(false); } } allResidences.Remove(residence); residence = null; return(true); }