public bool CanPurchase(string distributorID, string countryCode) { List <TaxIdentification> dsTins = DistributorOrderingProfileProvider.GetTinList(distributorID, true); //HMS made up the country code var countryCodes = new List <string>(CountryType.AR.HmsCountryCodes); countryCodes.Add(CountryType.AR.Key); bool arCOP = countryCodes.Contains(DistributorProfileModel.ProcessingCountryCode); if (arCOP && (dsTins == null || dsTins.Count == 0)) { return(false); } if (dsTins != null && dsTins.Any()) { List <string> arTinCodes = CountryTinCodeProvider.GetValidTinCodesForCountry(CountryType.AR.Key); var r = from a in arTinCodes from b in dsTins where a == b.IDType.Key select a; //Must have a TinCode to purchase if AR member if (arCOP && (r.Count() == 0)) { return(false); } bool hasARTX = (dsTins.Find(t => t.IDType.Key == "ARTX") != null); bool hasARVT = (dsTins.Find(t => t.IDType.Key == "ARVT") != null); bool hasCUIT = (dsTins.Find(t => t.IDType.Key == "CUIT") != null); bool hasARID = (dsTins.Find(t => t.IDType.Key == "ARID") != null); if ((hasARTX && hasARVT) || (hasARTX && hasARID && !hasCUIT) || (hasARVT && hasARID && !hasCUIT) || (hasARID && hasCUIT && !hasARTX && !hasARVT)) { return(false); } } return(true); }
public override bool CanPurchase(List <TaxIdentification> tins, string CountryOfProcessing, string CountyCode) { var countryCodes = new List <string>(CountryType.AR.HmsCountryCodes); countryCodes.Add(CountryType.AR.Key); bool arCOP = countryCodes.Contains(DistributorProfileModel.ProcessingCountryCode); if (arCOP && (tins == null || tins.Count == 0)) { return(false); } if (tins != null && tins.Any()) { List <string> arTinCodes = CountryTinCodeProvider.GetValidTinCodesForCountry(CountryType.AR.Key); var r = from a in arTinCodes from b in tins where a == b.IDType.Key select a; //Must have a TinCode to purchase if AR member if (arCOP && (r.Count() == 0)) { return(false); } bool hasARTX = (tins.Find(t => t.IDType.Key == "ARTX") != null); bool hasARVT = (tins.Find(t => t.IDType.Key == "ARVT") != null); bool hasCUIT = (tins.Find(t => t.IDType.Key == "CUIT") != null); bool hasARID = (tins.Find(t => t.IDType.Key == "ARID") != null); if ((hasARTX && hasARVT) || (hasARTX && hasARID && !hasCUIT) || (hasARVT && hasARID && !hasCUIT) || (hasARID && hasCUIT && !hasARTX && !hasARVT)) { return(false); } } return(true); }