public static CountryDTO[] ActiveCountriesLOV(this object obj) { if (_activeCountries.Count > 0) { return(_activeCountries.ToArray()); } _activeCountries = _geoServices.ActiveCountries().OrderBy(x => (x.Index ?? 9999)).ThenBy(x => x.CountryName).ToList(); return(_activeCountries.ToArray()); }
private bool IsAddressValid(ref BillingAddressDTO address, out string error) { error = string.Empty; if (address == null) { error = "address required"; return(false); } if (address.CountryId == null) { error = "Country required"; return(false); } if (address.CountryId != null && Constants.COUNTRIES_WITH_STATES.Contains((int)address.CountryId) && address.StateId == null) { error = "State required"; return(false); } if (String.IsNullOrEmpty(address.PostalCode)) { error = "Postal code required"; return(false); } if (String.IsNullOrEmpty(address.City)) { error = "City required"; return(false); } if (String.IsNullOrEmpty(address.Street1)) { error = "Street required"; return(false); } if (String.IsNullOrEmpty(address.BillingFirstName)) { error = "Billing FirstName required"; return(false); } if (String.IsNullOrEmpty(address.BillingLastName)) { error = "Billing LastName required"; return(false); } var cid = address.CountryId; var country = _geoServices.ActiveCountries().FirstOrDefault(x => x.CountryId == cid); if (country != null) { address.CountryCode = country.A2; } else { error = "country not found"; return(false); } if (address.StateId != null) { var sid = address.StateId; var state = _geoServices.GetStates((short)cid).FirstOrDefault(x => x.StateId == sid); if (state != null) { address.StateCode = state.StateCode; } } address.UserId = CurrentUserId; return(true); }