public static PostalAddress CreateIfNotEmpty(string street, string city, string postalCode = null, Alpha2CountryCode countryCode = null, string houseNumber = null, string boxNumber = null) { if (string.IsNullOrWhiteSpace(street)) { return(null); } if (string.IsNullOrWhiteSpace(city)) { return(null); } return(new PostalAddress ( street, city, postalCode, countryCode, houseNumber, boxNumber )); }
public PostalAddress(string street, string city, string postalCode = null, Alpha2CountryCode countryCode = null, string houseNumber = null, string boxNumber = null) { Condition.Requires(street, nameof(street)).IsNotNullOrWhiteSpace(); Condition.Requires(city, nameof(city)).IsNotNullOrWhiteSpace(); this.Street = street.ToTitleCase(); this.City = city.ToTitleCase(); if (!string.IsNullOrWhiteSpace(postalCode)) { this.PostalCode = postalCode.ToUpper(); } this.CountryCode = countryCode; if (!string.IsNullOrWhiteSpace(houseNumber)) { this.HouseNumber = houseNumber.ToUpper(); } if (!string.IsNullOrWhiteSpace(boxNumber)) { this.BoxNumber = boxNumber.ToUpper(); } }
public static PostalAddress FromState(PostalAddressState state) { if (state == null) { return(null); } return(CreateIfNotEmpty ( state.Street, state.City, state.PostalCode, Alpha2CountryCode.CreateIfNotEmpty(state.CountryCode), state.HouseNumber, state.BoxNumber )); }