private static int CompareUsingPostalCode(TFormData A, TFormData B) { TFormDataPartner P1 = A as TFormDataPartner; TFormDataPartner P2 = B as TFormDataPartner; if ((P1 == null) || (P2 == null)) { throw new ArgumentException("Cannot sort the form data because it is not related to Partner details."); } string code1 = P1.PostalCode; string code2 = P2.PostalCode; // Remove any spaces in the code (eg GB codes can have a space) code1 = code1.Replace(" ", ""); code2 = code2.Replace(" ", ""); // Special cases: // Switzerland uses CH- prefix sometimes if (code1.StartsWith("CH-")) { code1 = code1.Substring(3); } if (code2.StartsWith("CH-")) { code2 = code2.Substring(3); } return(CompareInternal(code1, code2)); }
private static int CompareUsingCountryName(TFormData A, TFormData B) { TFormDataPartner P1 = A as TFormDataPartner; TFormDataPartner P2 = B as TFormDataPartner; if ((P1 == null) || (P2 == null)) { throw new ArgumentException("Cannot sort the form data because it is not related to Partner details."); } return(CompareInternal(P1.CountryName, P2.CountryName)); }
private static int CompareUsingPostCodeRegion(TFormData A, TFormData B) { TFormDataPartner P1 = A as TFormDataPartner; TFormDataPartner P2 = B as TFormDataPartner; if ((P1 == null) || (P2 == null)) { throw new ArgumentException("Cannot sort the form data because it is not related to Partner details."); } // At the moment TFormDataPartner does not have a PostcodeRegion property throw new NotImplementedException(); }
private static int CompareUsingFirstNameLastName(TFormData A, TFormData B) { TFormDataPartner P1 = A as TFormDataPartner; TFormDataPartner P2 = B as TFormDataPartner; if ((P1 == null) || (P2 == null)) { throw new ArgumentException("Cannot sort the form data because it is not related to Partner details."); } int byFirstName = CompareInternal(P1.FirstName, P2.FirstName); if (byFirstName != 0) { return(byFirstName); } return(CompareInternal(P1.LastName, P2.LastName)); }