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 State GetStateById(long?id) { GetStateByIdCommand getStateByIdCommand = new GetStateByIdCommand(id); getStateByIdCommand.Execute(); return(getStateByIdCommand.CommandResult); }