Exemplo n.º 1
0
    private void LoadDictionary(DataSet ds)
    {
        // Retrieving the list of Cities to find the City of each House.
        CityList cityList = new CityList();
        // Retrieving the list of Countries to find the Country of each House.
        CountryList countryList = new CountryList();
        // Retrieving the list of Clients to find the Seller assigned to each House.
        ClientList clientList = new ClientList();

        foreach (DataRow row in ds.Tables[0].Rows)
        {
            House house = new House();
            house.HouseId      = (int)row["HouseId"];
            house.BuildingType = (BuildingType)row["BuildingTypeId"];
            house.Street       = row["Street"].ToString();
            house.ApartmentNo  = row["ApartmentNo"].ToString();
            house.PostalCode   = row["PostalCode"].ToString();
            house.City         = cityList.FindByCityId((int)row["CityId"]);
            house.Country      = countryList.FindByCountryId((int)row["CountryId"]);
            house.MakingYear   = row["MakingYear"].ToString();

            int bathrooms = default(int);
            int.TryParse(row["Bathrooms"].ToString(), out bathrooms);
            house.Bathrooms = bathrooms;

            int bedrooms = default(int);
            int.TryParse(row["Bedrooms"].ToString(), out bedrooms);
            house.Bedrooms = bedrooms;

            house.Area        = (double)row["Area"];
            house.Description = row["Description"].ToString();
            house.Price       = (double)row["Price"];
            house.Tax         = (double)row["Tax"];
            house.Seller      = clientList.FindByClientId((int)row["SellerId"]);

            _list.Add(house.HouseId, house);
        }
    }