public void AddApartmentForRent() { Console.Write("Apartment ID: "); int id = int.Parse(Console.ReadLine()); Console.Write("Address: "); string address = Console.ReadLine(); Console.Write("SquareMeters: "); int sm = int.Parse(Console.ReadLine()); Console.Write("NumberOfRooms"); int num = int.Parse(Console.ReadLine()); var apartment = new Apartment { ID = id, Address = address, SquareMeters = sm, NumberOfRooms = num }; ApartmentsForRent.Add(apartment); }
private void RentApartment() { Console.WriteLine("Available apartments for rent: "); foreach (var apartment in ApartmentsForRent) { apartment.Print(); } Console.WriteLine("Choose by typing the id of the apartment! "); int apartmentID = int.Parse(Console.ReadLine()); Console.WriteLine("Write you name:"); string name = Console.ReadLine(); Console.WriteLine("NumberO of Days:"); int days = int.Parse(Console.ReadLine()); var tempApartment = new Apartment(); foreach (var apartment1 in ApartmentsForRent) { if (apartment1.ID == apartmentID) { tempApartment = apartment1; } } var apartmentRent = new ApartmentRent { ID = apartmentID, LesseeName = name, NumberOfDays = days, PricePerDay = 20.0, Apartment = tempApartment, EntryDate = DateTime.Now }; ApartmentRents.Add(apartmentRent); ApartmentsForRent.Remove(tempApartment); }