public RentContract FindRentContract(int?id)
        {
            RentContract contract = null;

            foreach (var rent in GetRentContracts())
            {
                if (rent.RentContractID == id)
                {
                    contract = rent;
                    break;
                }
            }

            return(contract);
        }
        public List <RentContract> GetRentContracts()
        {
            List <RentContract> rentContracts = new List <RentContract>();

            using (SqlConnection scApartmentsManagement = new SqlConnection(System.
                                                                            Configuration.
                                                                            ConfigurationManager.
                                                                            ConnectionStrings["csApartmentsRentalManagement"].
                                                                            ConnectionString))
            {
                SqlCommand cmdRentContracts = new SqlCommand("SELECT RentContractID, ContractNumber, EmployeeID, " +
                                                             "       ContractDate, FirstName, LastName, " +
                                                             "       MaritalStatus, NumberOfChildren, " +
                                                             "       ApartmentID, RentStartDate " +
                                                             "FROM   Management.RentContracts;",
                                                             scApartmentsManagement);

                scApartmentsManagement.Open();
                cmdRentContracts.ExecuteNonQuery();

                SqlDataAdapter sdaRentContracts = new SqlDataAdapter(cmdRentContracts);
                DataSet        dsRentContracts  = new DataSet("rent-contracts");

                sdaRentContracts.Fill(dsRentContracts);

                for (int i = 0; i < dsRentContracts.Tables[0].Rows.Count; i++)
                {
                    RentContract contract = new RentContract()
                    {
                        RentContractID   = int.Parse(dsRentContracts.Tables[0].Rows[i][0].ToString()),
                        ContractNumber   = int.Parse(dsRentContracts.Tables[0].Rows[i][1].ToString()),
                        EmployeeID       = int.Parse(dsRentContracts.Tables[0].Rows[i][2].ToString()),
                        ContractDate     = DateTime.Parse(dsRentContracts.Tables[0].Rows[i][3].ToString()),
                        FirstName        = dsRentContracts.Tables[0].Rows[i][4].ToString(),
                        LastName         = dsRentContracts.Tables[0].Rows[i][5].ToString(),
                        MaritalStatus    = dsRentContracts.Tables[0].Rows[i][6].ToString(),
                        NumberOfChildren = int.Parse(dsRentContracts.Tables[0].Rows[i][7].ToString()),
                        ApartmentID      = int.Parse(dsRentContracts.Tables[0].Rows[i][8].ToString()),
                        RentStartDate    = DateTime.Parse(dsRentContracts.Tables[0].Rows[i][9].ToString())
                    };

                    rentContracts.Add(contract);
                }
            }

            return(rentContracts);
        }