public static string FormatForExigo(this string value, ExigoDataFormatType type) { string s = value.TrimStart(' ').TrimEnd(' '); s = FormatByType(s, type); return(s); }
/// <summary> /// Formats the value of the TextBox based on the procedures defined for the supplied ExigoDataFormatType. Used for cleaning up data that will be saved to Exigo. /// </summary> /// <param name="value"></param> /// <param name="type"></param> /// <returns>string</returns> public static string FormatForExigo(this TextBox textBox, ExigoDataFormatType type) { string s = textBox.Text.TrimStart(' ').TrimEnd(' '); s = FormatByType(s, type); return(s); }
private static string FormatByType(string value, ExigoDataFormatType type) { string s = value; switch (type) { case ExigoDataFormatType.Phone: s = s.Replace("-", "").Replace(" ", "").Replace(".", "").Replace("(", "").Replace(")", ""); break; case ExigoDataFormatType.TaxID: s = s.Replace("-", "").Replace(" ", "").Replace(".", ""); break; case ExigoDataFormatType.Email: s = s.Replace(" ", "").ToLower(); break; case ExigoDataFormatType.Username: s = s.Replace(" ", "").ToLower(); break; case ExigoDataFormatType.WebAlias: s = s.Replace(" ", "").ToLower(); break; case ExigoDataFormatType.CreditCardNumber: s = s.Replace("-", "").Replace(" ", "").Replace(".", ""); break; case ExigoDataFormatType.BankAccountNumber: s = s.Replace("-", "").Replace(" ", "").Replace(".", ""); break; case ExigoDataFormatType.BankRoutingNumber: s = s.Replace("-", "").Replace(" ", "").Replace(".", ""); break; default: throw new Exception(string.Format("'{0}' cannot be formatted for Exigo using Exigo.WebService;DataFormatType.{0}", value, type.ToString())); } return(s); }