Esempio n. 1
0
        public static Address GetAddress(this SqlDataReader reader)
        {
            Address address = new Address();

            if (reader.Read())
            {
                address.Id = reader.GetNullableValue <long>("AddressId");
                int item      = (int)reader["CityId"];
                int stateId   = (int)reader["StateId"];
                int countryId = (int)reader["CountryId"];
                GetCityByIdCommand    getCity    = new GetCityByIdCommand(new long?((long)item));
                GetStateByIdCommand   getState   = new GetStateByIdCommand(new long?((long)stateId));
                GetCountryByIdCommand getCountry = new GetCountryByIdCommand(new long?((long)countryId));
                getCity.Execute();
                getState.Execute();
                getCountry.Execute();
                address.City               = getCity.CommandResult;
                address.State              = getState.CommandResult;
                address.Country            = getCountry.CommandResult;
                address.StreetAddress      = reader["AddressLine1"].ToString();
                address.PostalCode         = reader["PostalCode"].ToString();
                address.Location.Latitude  = reader.GetValue <double>("Latitude");
                address.Location.Longitude = reader.GetValue <double>("Longitude");
            }
            return(address);
        }
        public Country GetCountryById(long?id)
        {
            GetCountryByIdCommand getCountryByIdCommand = new GetCountryByIdCommand(id);

            getCountryByIdCommand.Execute();
            return(getCountryByIdCommand.CommandResult);
        }