/// <summary> /// Gets all tax rates by params /// </summary> /// <param name="taxCategoryId">The tax category identifier</param> /// <param name="countryId">The country identifier</param> /// <param name="stateProvinceId">The state/province identifier</param> /// <param name="zip">The zip</param> /// <returns>Tax rate collection</returns> public static TaxRateCollection GetAllTaxRates(int taxCategoryId, int countryId, int stateProvinceId, string zip) { if (zip == null) { zip = string.Empty; } if (!String.IsNullOrEmpty(zip)) { zip = zip.Trim(); } var existingRates = GetAllTaxRates().FindTaxRates(countryId, taxCategoryId); //filter by state/province var matchedByStateProvince = new TaxRateCollection(); foreach (var taxRate in existingRates) { if (stateProvinceId == taxRate.StateProvinceId) { matchedByStateProvince.Add(taxRate); } } if (matchedByStateProvince.Count == 0) { foreach (var taxRate in existingRates) { if (taxRate.StateProvinceId == 0) { matchedByStateProvince.Add(taxRate); } } } //filter by zip var matchedByZip = new TaxRateCollection(); foreach (var taxRate in matchedByStateProvince) { if (zip.ToLower() == taxRate.Zip.ToLower()) { matchedByZip.Add(taxRate); } } if (matchedByZip.Count == 0) { foreach (var taxRate in matchedByStateProvince) { if (taxRate.Zip.Trim() == string.Empty) { matchedByZip.Add(taxRate); } } } return(matchedByZip); }
/// <summary> /// Gets all tax rates by params /// </summary> /// <param name="TaxCategoryID">The tax category identifier</param> /// <param name="CountryID">The country identifier</param> /// <param name="StateProvinceID">The state/province identifier</param> /// <param name="Zip">The zip</param> /// <returns>Tax rate collection</returns> public static TaxRateCollection GetAllTaxRates(int TaxCategoryID, int CountryID, int StateProvinceID, string Zip) { if (Zip == null) { Zip = string.Empty; } if (!String.IsNullOrEmpty(Zip)) { Zip = Zip.Trim(); } TaxRateCollection existingRates = GetAllTaxRates().FindTaxRates(CountryID, TaxCategoryID); //filter by state/province TaxRateCollection matchedByStateProvince = new TaxRateCollection(); foreach (TaxRate taxRate in existingRates) { if (StateProvinceID == taxRate.StateProvinceID) { matchedByStateProvince.Add(taxRate); } } if (matchedByStateProvince.Count == 0) { foreach (TaxRate taxRate in existingRates) { if (taxRate.StateProvinceID == 0) { matchedByStateProvince.Add(taxRate); } } } //filter by zip TaxRateCollection matchedByZip = new TaxRateCollection(); foreach (TaxRate taxRate in matchedByStateProvince) { if (Zip.ToLower() == taxRate.Zip.ToLower()) { matchedByZip.Add(taxRate); } } if (matchedByZip.Count == 0) { foreach (TaxRate taxRate in matchedByStateProvince) { if (taxRate.Zip.Trim() == string.Empty) { matchedByZip.Add(taxRate); } } } return(matchedByZip); }
/// <summary> /// Find records /// </summary> /// <param name="countryId">Country identifier</param> /// <param name="taxCategoryId">Tax category identifier</param> /// <returns>Tax rates</returns> public TaxRateCollection FindTaxRates(int countryId, int taxCategoryId) { TaxRateCollection result = new TaxRateCollection(); foreach (TaxRate taxRate in this) { if (taxRate.CountryId == countryId && taxRate.TaxCategoryId == taxCategoryId) { result.Add(taxRate); } } return(result); }
private static TaxRateCollection DBMapping(DBTaxRateCollection dbCollection) { if (dbCollection == null) { return(null); } var collection = new TaxRateCollection(); foreach (var dbItem in dbCollection) { var item = DBMapping(dbItem); collection.Add(item); } return(collection); }