public List<AddressType> Get(AddressTypes request) { AddressTypeRepository repository = GetAddressTypeRepository(); List<AddressTypeEntity> entities = repository.Read(); return entities.TranslateToResponse(); }
private void Init() { this.StoreId = 0; this.NickName = string.Empty; this.FirstName = string.Empty; this.MiddleInitial = string.Empty; this.LastName = string.Empty; this.Company = string.Empty; this.Line1 = string.Empty; this.Line2 = string.Empty; this.Line3 = string.Empty; this.City = string.Empty; this.RegionName = string.Empty; this.RegionBvin = string.Empty; this.PostalCode = string.Empty; this.CountryName = "US"; this.CountryBvin = MerchantTribe.Web.Geography.Country.FindByISOCode("US").Bvin; this.CountyBvin = string.Empty; this.CountyName = string.Empty; this.Phone = string.Empty; this.Fax = string.Empty; this.WebSiteUrl = string.Empty; this.UserBvin = string.Empty; this.AddressType = AddressTypes.General; this.LastUpdatedUtc = DateTime.UtcNow; }
public void btnNewAddress_Click(object sender, EventArgs e) { if (this.IsValid) { var AddressType = AddressTypeString.TryParseEnum <AddressTypes>(); int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber"); bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"); if (!AllowShipToDifferentThanBillTo) { //Shipping and Billing address must be the same so save both AddressType = AddressTypes.Shared; } Address thisAddress = new Address(); thisAddress.ThisCustomer = ThisCustomer; thisAddress.CustomerCode = ThisCustomer.CustomerCode; thisAddress.Name = ctrlAddress.AccountName; thisAddress.Address1 = ctrlAddress.Address; thisAddress.City = ctrlAddress.City; thisAddress.State = ctrlAddress.State; thisAddress.PostalCode = ctrlAddress.PostalCode; thisAddress.Country = ctrlAddress.CountryCode; thisAddress.Phone = ctrlAddress.PhoneNumber; thisAddress.County = ctrlAddress.County; thisAddress.ResidenceType = ctrlAddress.ResidenceType; if (!CheckToValidate(thisAddress, AddressType)) { switch (AddressType) { case AddressTypes.Shared: InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary); InterpriseHelper.AddCustomerShipTo(thisAddress); break; case AddressTypes.Billing: InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary); break; case AddressTypes.Shipping: InterpriseHelper.AddCustomerShipTo(thisAddress); break; } Response.Redirect(String.Format("selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}", checkOutMode.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL))); } } }
public List <Address> FindByType(AddressTypes t) { var storeId = Context.CurrentStore.Id; return(FindListPoco(q => { return q.Where(y => y.StoreId == storeId) .Where(y => y.AddressType == (int)t) .OrderBy(y => y.Id); })); }
public AddressValidationResult Validate(Address address, AddressTypes addressType = AddressTypes.Unknown) { if (AppLogic.ValidatePostalCode(address.Zip, AppLogic.GetCountryID(address.Country))) { return(new AddressValidationResult()); } else { return(new AddressValidationResult(AddressValidationStatus.Failure, AppLogic.GetCountryIsInternational(address.Country) ? "Invalid format of zip code:" : "Invalid format of postal code:")); } }
public AddressValidationResult Validate(Address address, AddressTypes addressType = AddressTypes.Unknown) { if (AppLogic.ValidatePostalCode(address.Zip, AppLogic.GetCountryID(address.Country))) { return(new AddressValidationResult()); } else { return(new AddressValidationResult(AddressValidationStatus.Failure, AppLogic.GetCountryIsInternational(address.Country) ? AppLogic.GetString("checkoutaddress.invalidzip") : AppLogic.GetString("checkoutaddress.invalidzip.international"))); } }
/// <summary> /// Get address types for specified locale. /// </summary> /// <param name="locale">Locale.</param> /// <returns>Address types for specified locale.</returns> protected override AddressTypeList GetAddressTypes(ILocale locale) { AddressTypeList addressTypes = null; lock (AddressTypes) { if (AddressTypes.ContainsKey(locale.ISOCode)) { addressTypes = (AddressTypeList)(AddressTypes[locale.ISOCode]); } } return(addressTypes); }
internal Sockaddr(IntPtr sockaddrPtr) { // A sockaddr struct. We use this to determine the address family PcapUnmanagedStructures.sockaddr saddr; // Marshal memory pointer into a struct saddr = (PcapUnmanagedStructures.sockaddr)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr)); // record the sa_family for informational purposes _sa_family = saddr.sa_family; byte[] addressBytes; if (saddr.sa_family == Pcap.AF_INET) { type = AddressTypes.AF_INET_AF_INET6; PcapUnmanagedStructures.sockaddr_in saddr_in = (PcapUnmanagedStructures.sockaddr_in)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr_in)); ipAddress = new System.Net.IPAddress(saddr_in.sin_addr.s_addr); } else if (saddr.sa_family == Pcap.AF_INET6) { type = AddressTypes.AF_INET_AF_INET6; addressBytes = new byte[16]; PcapUnmanagedStructures.sockaddr_in6 sin6 = (PcapUnmanagedStructures.sockaddr_in6)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr_in6)); Array.Copy(sin6.sin6_addr, addressBytes, addressBytes.Length); ipAddress = new System.Net.IPAddress(addressBytes); } else if (saddr.sa_family == Pcap.AF_PACKET) { type = AddressTypes.HARDWARE; PcapUnmanagedStructures.sockaddr_ll saddr_ll = (PcapUnmanagedStructures.sockaddr_ll)Marshal.PtrToStructure(sockaddrPtr, typeof(PcapUnmanagedStructures.sockaddr_ll)); byte[] hardwareAddressBytes = new byte[saddr_ll.sll_halen]; for (int x = 0; x < saddr_ll.sll_halen; x++) { hardwareAddressBytes[x] = saddr_ll.sll_addr[x]; } hardwareAddress = new PhysicalAddress(hardwareAddressBytes); // copy into the PhysicalAddress class } else { type = AddressTypes.UNKNOWN; // place the sockaddr.sa_data into the hardware address just in case // someone wants access to the bytes byte[] hardwareAddressBytes = new byte[saddr.sa_data.Length]; for (int x = 0; x < saddr.sa_data.Length; x++) { hardwareAddressBytes[x] = saddr.sa_data[x]; } hardwareAddress = new PhysicalAddress(hardwareAddressBytes); } }
void DisplayErrorIfAny(AddressTypes typeToValidate) { var cityTextBoxControl = (ctrlAddress.FindControl("WithStateCity") as WebControl); var postalTextBoxControl = (ctrlAddress.FindControl("WithStatePostalCode") as WebControl); if (this.hidBillCheck.Value.IsNullOrEmptyTrimmed() && this.hidShipCheck.Value.IsNullOrEmptyTrimmed()) { return; } cityTextBoxControl.CssClass = cityTextBoxControl.CssClass.Replace(" mobile-text-error", String.Empty); postalTextBoxControl.CssClass = postalTextBoxControl.CssClass.Replace(" mobile-text-error", String.Empty); if (typeToValidate == AddressTypes.Billing) { switch (this.hidBillCheck.Value) { case "IsInvalidCityOnly": cityTextBoxControl.CssClass = cityTextBoxControl.CssClass + " mobile-text-error"; break; case "IsInvalidPostalOnly": postalTextBoxControl.CssClass = postalTextBoxControl.CssClass + " mobile-text-error"; break; case "IsInvalidPostalAndCity": cityTextBoxControl.CssClass = cityTextBoxControl.CssClass + " mobile-text-error"; postalTextBoxControl.CssClass = postalTextBoxControl.CssClass + " mobile-text-error"; break; } } else { switch (this.hidShipCheck.Value) { case "IsInvalidCityOnly": cityTextBoxControl.CssClass = cityTextBoxControl.CssClass + " mobile-text-error"; break; case "IsInvalidPostalOnly": postalTextBoxControl.CssClass = postalTextBoxControl.CssClass + " mobile-text-error"; break; case "IsInvalidPostalAndCity": cityTextBoxControl.CssClass = cityTextBoxControl.CssClass + " mobile-text-error"; postalTextBoxControl.CssClass = postalTextBoxControl.CssClass + " mobile-text-error"; break; } } }
private void PerformPageAccessLogic() { ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL"); if (ReturnURL.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1) { throw new ArgumentException("SECURITY EXCEPTION"); } AddressTypeString = CommonLogic.QueryStringCanBeDangerousContent("AddressType"); if (AddressTypeString.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1) { throw new ArgumentException("SECURITY EXCEPTION"); } ThisCustomer.RequireCustomerRecord(); if (CommonLogic.QueryStringBool("editaddress") && !ThisCustomer.IsRegistered) { string url = CommonLogic.IIF(AppLogic.AppConfigBool("Checkout.UseOnePageCheckout"), "checkout1.aspx", String.Format("createaccount.aspx?checkout=true&skipreg=true&editaddress=true")); Response.Redirect(url); } if (!Shipping.MultiShipEnabled()) { RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING")); } if (AddressTypeString.Length != 0) { AddressType = (AddressTypes)Enum.Parse(typeof(AddressTypes), AddressTypeString, true); } if (AddressType == AddressTypes.Unknown) { AddressType = AddressTypes.Shipping; AddressTypeString = "Shipping"; } custAddresses = new Addresses(); custAddresses.LoadCustomer(ThisCustomer, AddressType); if (AddressType == AddressTypes.Shipping) { ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisshippingaddress.gif", ThisCustomer.LocaleSetting); } else { ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisbillingaddress.gif", ThisCustomer.LocaleSetting); } }
//public ClientHeaderModel dummyClientHeaderModel { get; set; } public IndexModel(IAPIHelper apiHelper, IRazorPartialToStringRenderer renderer, IModelHelper modelHelper) { _apiHelper = apiHelper; _renderer = renderer; _modelHelper = modelHelper; //SelectList creation StatusTypes statusTypes = new StatusTypes(); ContactTitles contactTitles = new ContactTitles(); AddressTypes addressTypes = new AddressTypes(); StatusList = new SelectList(statusTypes.GetStatusTypesDictionary(), "Key", "Value"); TitleList = new SelectList(contactTitles.GetContactTitlesDictionary(), "Key", "Value"); AddressTypeList = new SelectList(addressTypes.GetAddressTypesDictionary(), "Key", "Value"); }
/** * @param country * `Country` and `State` are Country code (like "US") and State * code (like "NY"), note that the full value is available as * address.CountryFull and address.StateFull. * @param state * `Country` and `State` are Country code (like "US") and State * code (like "NY"), note that the full value is available as * address.CountryFull and address.StateFull. * @param city * City * @param poBox * PoBox * @param street * Street * @param house * House * @param apartment * Apartment * @param raw * `raw` is an unparsed address like "123 Marina Blvd, San * Francisco, California, US", useful when you want to search by * address and don't want to work hard to parse it. Note that in * response data there's never address.Raw, the addresses in the * response are always parsed, this is only for querying with an * unparsed address. * @param type * Type is one of "home", "work", "old" * @param zip_code * ZipCode * @param validSince * `validSince` is a <code>DateTime</code> object, it's the first * time Pipl's crawlers found this data on the page. */ public Address(string country = null, string state = null, string city = null, string poBox = null, string street = null, string house = null, string apartment = null, string raw = null, AddressTypes? type = null, string zip_code = null, DateTime? validSince = null) : base(validSince) { this.Country = country; this.State = state; this.City = city; this.PoBox = poBox; this.Street = street; this.House = house; this.Apartment = apartment; this.Raw = raw; this.Type = type; this.ZipCode = zip_code; }
public void btnNewAddress_Click(object sender, EventArgs e) { if (this.IsValid) { var AddressType = AddressTypeString.TryParseEnum <AddressTypes>(); int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber"); bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"); if (!AllowShipToDifferentThanBillTo) { //Shipping and Billing address must be the same so save both AddressType = AddressTypes.Shared; } //changes for mobile design var thisAddress = ctrlAddress.ExtractAddress(ThisCustomer); thisAddress.CustomerCode = ThisCustomer.CustomerCode; thisAddress.Name = ctrlAddress.AccountName; if (!CheckToValidate(thisAddress, AddressType)) { switch (AddressType) { case AddressTypes.Shared: InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary); InterpriseHelper.AddCustomerShipTo(thisAddress); break; case AddressTypes.Billing: InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary); break; case AddressTypes.Shipping: InterpriseHelper.AddCustomerShipTo(thisAddress); break; } string url = "selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}".FormatWith(checkOutMode.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL)); Response.Redirect(url); } } }
public AddressValidationResult Validate(Address address, AddressTypes addressType = AddressTypes.Unknown) { if (address.Country != "United States") // Avalara doesn't validate other countries { return(new AddressValidationResult()); } var correctedAddress = new Address(); correctedAddress.LoadFromDB(address.AddressID); try { var result = new AvaTax() .ValidateAddress( customer: AppLogic.GetCurrentCustomer(), inputAddress: address, ResultAddress: out correctedAddress); if (string.IsNullOrEmpty(result)) { return(new AddressValidationResult( correctedAddresses: new[] { correctedAddress })); } else { return(new AddressValidationResult( status: AddressValidationStatus.Failure, message: result, correctedAddresses: new[] { correctedAddress })); } } catch (Exception exception) { return(new AddressValidationResult( status: AddressValidationStatus.Failure, message: exception.Message)); } }
internal Sockaddr(IntPtr sockaddrPtr) { // Marshal memory pointer into a struct var saddr = Marshal.PtrToStructure <sockaddr>(sockaddrPtr); // record the sa_family for informational purposes sa_family = saddr.sa_family; if (saddr.sa_family == Pcap.AF_INET) { type = AddressTypes.AF_INET_AF_INET6; var saddr_in = Marshal.PtrToStructure <sockaddr_in>(sockaddrPtr); ipAddress = new IPAddress(saddr_in.sin_addr.s_addr); } else if (saddr.sa_family == Pcap.AF_INET6) { type = AddressTypes.AF_INET_AF_INET6; var sin6 = Marshal.PtrToStructure <sockaddr_in6>(sockaddrPtr); ipAddress = new IPAddress(sin6.sin6_addr, sin6.sin6_scope_id); } else if (saddr.sa_family == Pcap.AF_PACKET) { type = AddressTypes.HARDWARE; var saddr_ll = Marshal.PtrToStructure <sockaddr_ll>(sockaddrPtr); var hwAddrBytes = new byte[saddr_ll.sll_halen]; Buffer.BlockCopy(saddr_ll.sll_addr, 0, hwAddrBytes, 0, hwAddrBytes.Length); hardwareAddress = new PhysicalAddress(hwAddrBytes); // copy into the PhysicalAddress class } else { type = AddressTypes.UNKNOWN; // place the sockaddr.sa_data into the hardware address just in case // someone wants access to the bytes byte[] hardwareAddressBytes = new byte[saddr.sa_data.Length]; for (int x = 0; x < saddr.sa_data.Length; x++) { hardwareAddressBytes[x] = saddr.sa_data[x]; } hardwareAddress = new PhysicalAddress(hardwareAddressBytes); } }
public ActionResult MakePrimaryAddress(int addressId, AddressTypes addressType, string returnUrl) { var customer = HttpContext.GetCustomer(); var address = ControllerHelper.GetCustomerAddress(addressId, customer); var safeReturnUrl = Url.MakeSafeReturnUrl(returnUrl, Url.Action(ActionNames.Index)); var verificationAddress = new Address(); verificationAddress.LoadFromDB(address.Id.Value); if (verificationAddress.CustomerID != customer.CustomerID) { throw new HttpException(404, null); } MakePrimary(customer, addressType, address); return(Redirect(safeReturnUrl)); }
/// <summary> /// Refresh cached data. /// </summary> /// <param name="userContext">User context.</param> protected override void RefreshCache(IUserContext userContext) { lock (AddressTypes) { AddressTypes.Clear(); } lock (MessageTypes) { MessageTypes.Clear(); } lock (PersonGenders) { PersonGenders.Clear(); } lock (PhoneNumberTypes) { PhoneNumberTypes.Clear(); } }
private void LoadFromAddress(Address addr) { if (addr != null) { AddressBvin = addr.Bvin; AddressTypeField = addr.AddressType; ddlCountries.SelectedValue = addr.CountryBvin; PopulateRegions(addr.CountryBvin); ddlRegions.SelectedValue = addr.RegionBvin; txtFirstName.Text = addr.FirstName; txtLastName.Text = addr.LastName; txtCompany.Text = addr.Company; txtAddressLine1.Text = addr.Line1; txtAddressLine2.Text = addr.Line2; txtCity.Text = addr.City; txtZip.Text = addr.PostalCode; txtPhone.Text = addr.Phone; } }
private void CheckDb() { Database.EnsureCreated(); var home = AddressTypes.Find(AddressType.Home.Id); if (home == null) { AddressTypes.Add(AddressType.Home); } var work = AddressTypes.Find(AddressType.Work.Id); if (work == null) { AddressTypes.Add(AddressType.Work); } if (home == null || work == null) { SaveChanges(); } }
public ActionResult SelectAddress(AddressTypes addressType) { var customer = HttpContext.GetCustomer(); var primaryAddressId = addressType == AddressTypes.Shipping ? customer.PrimaryShippingAddressID : customer.PrimaryBillingAddressID; var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var pageTitle = string.Empty; if (!AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo") || addressType == AddressTypes.Account) { pageTitle = AppLogic.GetString("checkoutaddress.chooseabillingandshippingaddress", customer.LocaleSetting); } else if (addressType == AddressTypes.Shipping) { pageTitle = AppLogic.GetString("checkoutaddress.chooseashippingaddress", customer.LocaleSetting); } else { pageTitle = AppLogic.GetString("checkoutaddress.chooseabillingaddress", customer.LocaleSetting); } var addresses = AddressControllerHelper.GetCustomerAddresses(customer); var model = new SelectAddressViewModel { SelectedAddressId = primaryAddressId, SelectedAddress = addresses .Where(address => address.Id == primaryAddressId) .FirstOrDefault(), AddressOptions = addresses, AddressType = addressType, PageTitle = pageTitle, AddressSelectionLocked = (addressType == AddressTypes.Billing && checkoutContext.OffsiteRequiredBillingAddressId.HasValue) || (addressType == AddressTypes.Shipping && checkoutContext.OffsiteRequiredShippingAddressId.HasValue) }; return(PartialView(ViewNames.SelectAddressPartial, model)); }
private void PerformPageAccessLogic() { ReturnURL = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL"); if (ReturnURL.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1) { throw new ArgumentException("SECURITY EXCEPTION"); } AddressTypeString = CommonLogic.QueryStringCanBeDangerousContent("AddressType"); if (AddressTypeString.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1) { throw new ArgumentException("SECURITY EXCEPTION"); } ThisCustomer.RequireCustomerRecord(); if (!Shipping.MultiShipEnabled()) { RequiresLogin(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING")); } if (AddressTypeString.Length != 0) { AddressType = (AddressTypes)Enum.Parse(typeof(AddressTypes), AddressTypeString, true); } if (AddressType == AddressTypes.Unknown) { AddressType = AddressTypes.Shipping; AddressTypeString = "Shipping"; } custAddresses = new Addresses(); custAddresses.LoadCustomer(ThisCustomer, AddressType); if (AddressType == AddressTypes.Shipping) { ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisshippingaddress.gif", ThisCustomer.LocaleSetting); } else { ButtonImage = AppLogic.LocateImageURL("skins/Skin_" + SkinID.ToString() + "/images/usethisbillingaddress.gif", ThisCustomer.LocaleSetting); } }
/// <summary> /// Sammelt die Namen der in <paramref name="addressType"/> gesetzten Flags in /// <paramref name="list"/>. <paramref name="list"/> wird von der Methode nicht /// geleert. /// </summary> /// <param name="addressType"><see cref="AddressTypes"/>-Objekt oder <c>null</c>.</param> /// <param name="list">Eine Liste zum sammeln.</param> internal static void CollectValueStrings(AddressTypes?addressType, List <string> list) { Debug.Assert(list != null); if (!addressType.HasValue) { return; } AddressTypes value = addressType.Value & AddressTypesConverter.DEFINED_ADDRESS_TYPES_VALUES; for (int i = AddressTypesConverter.AddressTypesMinBit; i <= AddressTypesConverter.AddressTypesMaxBit; i++) { AddressTypes flag = (AddressTypes)(1 << i); if (value.HasFlag(flag)) { list.Add(flag.ToVcfString()); } } }
/// <summary> /// This is used to store the value of the address type checkbox /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void CheckBox_Parse(object sender, ConvertEventArgs e) { AddressProperty a = (AddressProperty)this.BindingSource.Current; CheckBox cb = (CheckBox)((Binding)sender).Control; AddressTypes checkType = (AddressTypes)cb.Tag; if (cb.Checked) { a.AddressTypes |= checkType; } else { a.AddressTypes &= ~checkType; } // Only one address can be the preferred address if (checkType == AddressTypes.Preferred) { ((AddressPropertyCollection)this.BindingSource.DataSource).SetPreferred(a); } }
public string GetHeaderText(int?addressId, AddressTypes addressType) { //Does this address already exist? var editing = addressId != null; //This way the entire final string can be properly translated switch (addressType) { case AddressTypes.Billing: return(editing ? "Edit Billing Address" : "Add New Billing Address"); case AddressTypes.Shipping: return(editing ? "Edit Shipping Address" : "Add New BillingShipping Address"); default: return("Edit Address"); } }
public string GetHeaderText(int?addressId, AddressTypes addressType) { //Does this address already exist? var editing = addressId != null; //This way the entire final string can be properly translated switch (addressType) { case AddressTypes.Billing: return(editing ? AppLogic.GetString("address.editbilling") : AppLogic.GetString("address.addbilling")); case AddressTypes.Shipping: return(editing ? AppLogic.GetString("address.editshipping") : AppLogic.GetString("address.addshipping")); default: return(AppLogic.GetString("address.editaddress")); } }
protected void Page_Load(object sender, System.EventArgs e) { Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); RequireSecurePage(); Checkout = CommonLogic.QueryStringBool("checkout"); AddressTypes ats = DetermineAddressType(CommonLogic.QueryStringCanBeDangerousContent("AddressType").ToLowerInvariant()); String AddressTypeString = ats.ToString(); AddressID = CommonLogic.QueryStringUSInt("AddressID"); theAddress.LoadFromDB(AddressID); Prompt = CommonLogic.QueryStringCanBeDangerousContent("Prompt"); if (CommonLogic.QueryStringCanBeDangerousContent("RETURNURL") != "") { ViewState["RETURNURL"] = CommonLogic.QueryStringCanBeDangerousContent("RETURNURL"); } if (!ThisCustomer.OwnsThisAddress(AddressID)) { Response.Redirect("default.aspx"); } AppLogic.CheckForScriptTag(AddressTypeString); SectionTitle = "<a href=\"selectaddress.aspx?checkout=" + Checkout.ToString() + "&AddressType=" + AddressTypeString + "\">" + String.Format(AppLogic.GetString("selectaddress.aspx.1", SkinID, ThisCustomer.LocaleSetting), AddressTypeString) + "</a> → "; SectionTitle += AppLogic.GetString("editaddress.aspx.1", SkinID, ThisCustomer.LocaleSetting); AddressType = DetermineAddressType(AddressTypeString); CanDelete = (0 == DB.GetSqlN(String.Format("select count(0) as N from ShoppingCart with (NOLOCK) where (ShippingAddressID={0} or BillingAddressID={0}) and CartType={1}", AddressID, (int)CartTypeEnum.RecurringCart))); if (!IsPostBack) { InitializePageContent(); } }
/// <summary> /// This method can be used to find the first address that has one of the specified address types /// </summary> /// <param name="addrType">The address type to match</param> /// <returns>The first address with an address type matching one of those specified or null if not found</returns> /// <remarks>Multiple address types can be specified. Including <c>Preferred</c> will limit the match to /// the one with the <c>Preferred</c> flag set. If a preferred address with one of the given types /// cannot be found, it will return the first address matching one of the given types without the /// <c>Preferred</c> flag set. If no address can be found, it returns null.</remarks> public AddressProperty FindFirstByType(AddressTypes addrType) { AddressTypes addrNoPref = addrType & ~AddressTypes.Preferred; bool usePreferred = (addrNoPref != addrType); foreach (AddressProperty addr in this) { if ((addr.AddressTypes & addrNoPref) != 0 && (!usePreferred || (addr.AddressTypes & AddressTypes.Preferred) != 0)) { return(addr); } } // Try again without the preferred flag? if (usePreferred) { return(this.FindFirstByType(addrNoPref)); } return(null); }
public AddressValidationResult Validate(Address address, AddressTypes addressType = AddressTypes.Unknown) { if (!AppLogic.AppConfigBool("DisallowShippingToPOBoxes")) { return(new AddressValidationResult()); } if (addressType != AddressTypes.Shipping) { return(new AddressValidationResult()); } var regEx = new Regex(@"(?i)\b(?:p(?:ost)?\.?\s*[o0](?:ffice)?\.?\s*b(?:[o0]x)?|b[o0]x)"); if (regEx.IsMatch(address.Address1)) { return(new AddressValidationResult(AddressValidationStatus.Failure, "P.O. Box ship-to addresses are not supported. Please enter a full street residential or commercial address. Thanks")); } else { return(new AddressValidationResult()); } }
public AddressValidationResult Validate(Address address, AddressTypes addressType = AddressTypes.Unknown) { if (!AppLogic.AppConfigBool("DisallowShippingToPOBoxes")) { return(new AddressValidationResult()); } if (addressType != AddressTypes.Shipping) { return(new AddressValidationResult()); } var regEx = new Regex(@"(?i)\b(?:p(?:ost)?\.?\s*[o0](?:ffice)?\.?\s*b(?:[o0]x)?|b[o0]x)"); if (regEx.IsMatch(address.Address1)) { return(new AddressValidationResult(AddressValidationStatus.Failure, AppLogic.GetString("createaccount_process.aspx.3"))); } else { return(new AddressValidationResult()); } }
/// <summary> /// Set default values to each of the address properties /// </summary> private void Init() { StoreId = 0; NickName = string.Empty; FirstName = string.Empty; MiddleInitial = string.Empty; LastName = string.Empty; Company = string.Empty; Line1 = string.Empty; Line2 = string.Empty; Line3 = string.Empty; City = string.Empty; RegionName = string.Empty; RegionBvin = string.Empty; PostalCode = string.Empty; CountryName = string.Empty; CountryBvin = string.Empty; Phone = string.Empty; Fax = string.Empty; WebSiteUrl = string.Empty; UserBvin = string.Empty; AddressType = AddressTypes.General; LastUpdatedUtc = DateTime.UtcNow; }
private AddressType BuildAddressData(string aplId, string companyId, string address1, string address2, string address3, string address4, string email, string phoneNumber, string city, string state, string zip, AddressTypes addressType) { return(new AddressType() { ID = BuildIdData(aplId), CompanyName = companyId, Address1 = address1, Address2 = address2, Address3 = address3, Address4 = address4, Email = email, City = city, State = state, Zip = zip, Country = DefaultCountry, Type = addressType, TypeSpecified = true, Default = true, DefaultSpecified = true }); }
public AddressValidationResult Validate(Address address, AddressTypes addressType = AddressTypes.Unknown) { if (address.Country != "United States") // USPS can't verify non-US addresses { return(new AddressValidationResult()); } var result = AppLogic.ro_OK; var correctedAddress = new Address(); correctedAddress.LoadFromDB(address.AddressID); var requestDoc = new StringBuilder(); requestDoc.AppendFormat("API=Verify&Xml=<AddressValidateRequest USERID=\"{0}\">", AppLogic.AppConfig("VerifyAddressesProvider.USPS.UserID")); requestDoc.Append("<Address ID=\"0\">"); requestDoc.AppendFormat("<Address1>{0}</Address1>", address.Address2); requestDoc.AppendFormat("<Address2>{0}</Address2>", address.Address1); requestDoc.AppendFormat("<City>{0}</City>", address.City); requestDoc.AppendFormat("<State>{0}</State>", address.State); requestDoc.AppendFormat("<Zip5>{0}</Zip5>", address.Zip); requestDoc.Append("<Zip4></Zip4>"); requestDoc.Append("</Address>"); requestDoc.Append("</AddressValidateRequest>"); ; // Send request & capture response // Possible USPS server values: // http://production.shippingapis.com/shippingapi.dll // http://testing.shippingapis.com/ShippingAPITest.dll var received = XmlCommon.GETandReceiveData(requestDoc.ToString(), AppLogic.AppConfig("VerifyAddressesProvider.USPS.Server")); var response = new XmlDocument(); try { response.LoadXml(received); } catch { return(new AddressValidationResult()); // we don't want to bug the customer if the server did not respond. } // Check for error response from server var errors = response.GetElementsByTagName("Error"); if (errors.Count > 0) // Error has occurred { var error = response.GetElementsByTagName("Error"); var errorMessage = error.Item(0); result = AppLogic.GetString("uspsValidate" + errorMessage["Number"].InnerText, address.SkinID, address.LocaleSetting); if (result == "uspsValidate" + errorMessage["Number"].InnerText) { // Use the USPS Error Description for error messages we don't have String values for. result = string.Format("Address Verification Error: {0}", errorMessage["Description"].InnerText); } return(new AddressValidationResult( status: AddressValidationStatus.Failure, message: result)); } var addresses = response.GetElementsByTagName("Address"); if (addresses.Count > 0) { var uspsAddress = addresses.Item(0); // our address1 is their address2 correctedAddress.Address1 = uspsAddress["Address2"].InnerText; correctedAddress.Address2 = uspsAddress["Address1"] != null ? uspsAddress["Address1"].InnerText : String.Empty; correctedAddress.City = uspsAddress["City"].InnerText; correctedAddress.State = uspsAddress["State"].InnerText; correctedAddress.Zip = uspsAddress["Zip5"].InnerText; // add Zip+4 if it exists correctedAddress.Zip += uspsAddress["Zip4"].InnerText.Length == 4 ? "-" + uspsAddress["Zip4"].InnerText : String.Empty; correctedAddress.FirstName = correctedAddress.FirstName.ToUpperInvariant(); correctedAddress.LastName = correctedAddress.LastName.ToUpperInvariant(); correctedAddress.Company = correctedAddress.Company.ToUpperInvariant(); result = "Your shipping address has been formatted and validated according to US Postal Service standards. Please verify that it is correct."; // Does the resulting address matches the entered address? bool IsMatch = true; if (correctedAddress.Address1 != address.Address1) { IsMatch = false; } else if (correctedAddress.Address2 != address.Address2) { IsMatch = false; } else if (correctedAddress.City != address.City) { IsMatch = false; } else if (correctedAddress.State != address.State) { IsMatch = false; } //USPS is USA only - no check for country else if (correctedAddress.Zip != address.Zip) { IsMatch = false; } // If the resulting address matches the entered address, then return ro_OK if (IsMatch) { return(new AddressValidationResult()); } } else { // unknown response from server return(new AddressValidationResult()); // we don't want to bug the customer if we don't recognize the response. } return(new AddressValidationResult( status: AddressValidationStatus.Failure, message: result, correctedAddresses: new[] { correctedAddress })); }
/// <summary> /// This is overridden to allow copying of the additional properties /// </summary> /// <param name="p">The PDI object from which the settings are to be copied</param> protected override void Clone(PDIObject p) { this.AddressTypes = ((LabelProperty)p).AddressTypes; base.Clone(p); }
public void FromDto(AddressDTO dto) { this.StoreId = dto.StoreId; this.NickName = dto.NickName ?? string.Empty; this.FirstName = dto.FirstName ?? string.Empty; this.MiddleInitial = dto.MiddleInitial ?? string.Empty; this.LastName = dto.LastName ?? string.Empty; this.Company = dto.Company ?? string.Empty; this.Line1 = dto.Line1 ?? string.Empty; this.Line2 = dto.Line2 ?? string.Empty; this.Line3 = dto.Line3 ?? string.Empty; this.City = dto.City ?? string.Empty; this.RegionName = dto.RegionName ?? string.Empty; this.RegionBvin = dto.RegionBvin ?? string.Empty; this.PostalCode = dto.PostalCode ?? string.Empty; this.CountryName = dto.CountryName ?? string.Empty; this.CountryBvin = dto.CountryBvin ?? string.Empty; this.CountyBvin = dto.CountyBvin ?? string.Empty; this.CountyName = dto.CountyName ?? string.Empty; this.Phone = dto.Phone ?? string.Empty; this.Fax = dto.Fax ?? string.Empty; this.WebSiteUrl = dto.WebSiteUrl ?? string.Empty; this.UserBvin = dto.UserBvin ?? string.Empty; this.AddressType = (AddressTypes)((int)dto.AddressType); this.LastUpdatedUtc = dto.LastUpdatedUtc; }
public void btnNewAddress_Click(object sender, EventArgs e) { if (this.IsValid) { var AddressType = AddressTypeString.TryParseEnum <AddressTypes>(); int OriginalRecurringOrderNumber = CommonLogic.QueryStringUSInt("OriginalRecurringOrderNumber"); bool AllowShipToDifferentThanBillTo = AppLogic.AppConfigBool("AllowShipToDifferentThanBillTo"); if (!AllowShipToDifferentThanBillTo) { //Shipping and Billing address must be the same so save both AddressType = AddressTypes.Shared; } Address thisAddress = new Address(); thisAddress.ThisCustomer = ThisCustomer; thisAddress.CustomerCode = ThisCustomer.CustomerCode; string bCityStates = txtCityStates.Text; string city = string.Empty; string state = string.Empty; if (!string.IsNullOrEmpty(bCityStates)) { var _cityState = bCityStates.Split(','); if (_cityState.Length > 1) { state = _cityState[0].Trim(); city = _cityState[1].Trim(); } else { city = _cityState[0].Trim(); state = string.Empty; } } else { state = AddressControl.state; city = AddressControl.city; } thisAddress.Name = txtContactName.Text; thisAddress.Address1 = AddressControl.street; thisAddress.City = city; thisAddress.State = state; thisAddress.PostalCode = AddressControl.postal; thisAddress.Country = AddressControl.country; thisAddress.Phone = txtContactNumber.Text; if (AppLogic.AppConfigBool("Address.ShowCounty")) { thisAddress.County = AddressControl.county; } switch (AddressType) { case AddressTypes.Shared: thisAddress.ResidenceType = ResidenceTypes.Residential; InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary); InterpriseHelper.AddCustomerShipTo(thisAddress); break; case AddressTypes.Billing: thisAddress.ResidenceType = ResidenceTypes.Residential; InterpriseHelper.AddCustomerBillToInfo(ThisCustomer.CustomerCode, thisAddress, setPrimary); break; case AddressTypes.Shipping: if (AddressControl.residenceType == ResidenceTypes.Residential.ToString()) { thisAddress.ResidenceType = ResidenceTypes.Residential; } else { thisAddress.ResidenceType = ResidenceTypes.Commercial; } InterpriseHelper.AddCustomerShipTo(thisAddress); break; } AppLogic.SavePostalCode(thisAddress); Response.Redirect(String.Format("selectaddress.aspx?Checkout={0}&AddressType={1}&ReturnURL={2}", checkOutMode.ToString(), AddressTypeString, Server.UrlEncode(ReturnURL))); } }
/// <summary> /// Create a Sockaddr from a PhysicalAddress which is presumed to /// be a hardware address /// </summary> /// <param name="hardwareAddress"> /// A <see cref="PhysicalAddress"/> /// </param> public Sockaddr(PhysicalAddress hardwareAddress) { this.type = AddressTypes.HARDWARE; this.hardwareAddress = hardwareAddress; }
//===================================================================== /// <summary> /// Constructor. Unless the version is changed, the object will conform to the vCard 3.0 specification. /// </summary> public LabelProperty() { this.Version = SpecificationVersions.vCard30; this.AddressTypes = AddressTypes.Default; }
/// <summary> /// This is overridden to provide custom handling of the TYPE parameter /// </summary> /// <param name="parameters">The parameters for the property</param> public override void DeserializeParameters(StringCollection parameters) { string[] types; int idx, subIdx; if(parameters == null || parameters.Count == 0) return; AddressTypes at = AddressTypes.None; for(int paramIdx = 0; paramIdx < parameters.Count; paramIdx++) { for(idx = 0; idx < ntv.Length; idx++) if(ntv[idx].IsMatch(parameters[paramIdx])) break; if(idx == ntv.Length) { // If it was a parameter name, skip the value too if(parameters[paramIdx].EndsWith("=", StringComparison.Ordinal)) paramIdx++; continue; // Not a label parameter } // Parameters may appear as a pair (name followed by value) or by value alone if(!ntv[idx].IsParameterValue && paramIdx < parameters.Count - 1) { // Remove the TYPE parameter name so that the base class won't put it in the custom // parameters. We'll skip this one and decode the parameter value. parameters.RemoveAt(paramIdx); // If the values contain a comma, split it on the comma and parse the types (i.e. vCard 3.0 // spec). If not, just continue and handle it as normal. if(reSplit.IsMatch(parameters[paramIdx])) { types = reSplit.Split(parameters[paramIdx]); foreach(string s in types) { for(subIdx = 1; subIdx < ntv.Length; subIdx++) if(ntv[subIdx].IsMatch(s)) break; // Unrecognized ones are ignored if(subIdx < ntv.Length) at |= ntv[subIdx].EnumValue; } parameters.RemoveAt(paramIdx); } } else { at |= ntv[idx].EnumValue; // As above, remove the value parameters.RemoveAt(paramIdx); } paramIdx--; } if(at != AddressTypes.None) this.AddressTypes = at; // Let the base class handle all other parameters base.DeserializeParameters(parameters); }
public AddressViewModel(Address a) { Init(); this.StoreId = a.StoreId; this.NickName = a.NickName; this.FirstName = a.FirstName; this.MiddleInitial = a.MiddleInitial; this.LastName = a.LastName; this.Company = a.Company; this.Line1 = a.Line1; this.Line2 = a.Line2; this.Line3 = a.Line3; this.City = a.City; this.RegionName = a.RegionName; this.RegionBvin = a.RegionBvin; this.PostalCode = a.PostalCode; this.CountryName = a.CountryName; this.CountryBvin = a.CountryBvin; this.CountyBvin = a.CountyBvin; this.CountyName = a.CountyName; this.Phone = a.Phone; this.Fax = a.Fax; this.WebSiteUrl = a.WebSiteUrl; this.UserBvin = a.UserBvin; this.AddressType = a.AddressType; this.LastUpdatedUtc = a.LastUpdatedUtc; }
internal Address GetAddressType(AddressTypes type) { foreach(Address addr in currentContact.GetAddresses()) { if( (addr.Types & type) == type) return addr; } return null; }
public bool FromXml(ref XmlReader xr) { bool results = false; try { while (xr.Read()) { if (xr.IsStartElement()) { if (!xr.IsEmptyElement) { switch (xr.Name) { case "Bvin": xr.Read(); Bvin = xr.ReadString(); break; case "NickName": xr.Read(); NickName = xr.ReadString(); break; case "FirstName": xr.Read(); FirstName = xr.ReadString(); break; case "MiddleInitial": xr.Read(); MiddleInitial = xr.ReadString(); break; case "LastName": xr.Read(); LastName = xr.ReadString(); break; case "Company": xr.Read(); Company = xr.ReadString(); break; case "Line1": xr.Read(); Line1 = xr.ReadString(); break; case "Line2": xr.Read(); Line2 = xr.ReadString(); break; case "Line3": xr.Read(); Line3 = xr.ReadString(); break; case "City": xr.Read(); City = xr.ReadString(); break; case "RegionName": xr.Read(); RegionName = xr.ReadString(); break; case "RegionBvin": xr.Read(); RegionBvin = xr.ReadString(); break; case "PostalCode": xr.Read(); _PostalCode = xr.ReadString(); break; case "CountryName": xr.Read(); CountryName = xr.ReadString(); break; case "CountryBvin": xr.Read(); CountryBvin = xr.ReadString(); break; case "Phone": xr.Read(); Phone = xr.ReadString(); break; case "Fax": xr.Read(); Fax = xr.ReadString(); break; case "WebSiteUrl": xr.Read(); WebSiteUrl = xr.ReadString(); break; case "LastUpdated": xr.Read(); LastUpdatedUtc = DateTime.Parse(xr.ReadString()); break; case "CountyName": xr.Read(); CountyName = xr.ReadString(); break; case "CountyBvin": xr.Read(); CountyBvin = xr.ReadString(); break; case "UserBvin": xr.Read(); UserBvin = xr.ReadString(); break; //case "Residential": // xr.Read(); // Residential = bool.Parse(xr.ReadString()); // break; case "AddressType": xr.Read(); int tempType = int.Parse(xr.ReadString()); AddressType = (AddressTypes)tempType; break; } } } } results = true; } catch (XmlException XmlEx) { //EventLog.LogEvent(XmlEx); results = false; } return results; }