/// <summary> /// Gets parsed price ranges /// </summary> protected virtual IList <PriceRange> GetPriceRangeList(string priceRangesStr, Filter filter, IPriceCalculationService priceCalculationService) { IEnumerable <int> allPrices = new List <int>(); if (priceCalculationService != null) { allPrices = priceCalculationService.GetPriceAmountForFilter(filter); } var priceRanges = new List <PriceRange>(); if (string.IsNullOrWhiteSpace(priceRangesStr)) { return(priceRanges); } string[] rangeArray = priceRangesStr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string str1 in rangeArray) { string[] fromTo = str1.Trim().Split(new char[] { '-' }); decimal?from = null; if (!String.IsNullOrEmpty(fromTo[0]) && !String.IsNullOrEmpty(fromTo[0].Trim())) { from = decimal.Parse(fromTo[0].Trim(), new CultureInfo("en-US")); } decimal?to = null; if (!String.IsNullOrEmpty(fromTo[1]) && !String.IsNullOrEmpty(fromTo[1].Trim())) { to = decimal.Parse(fromTo[1].Trim(), new CultureInfo("en-US")); } var amount = allPrices.Count(x => x >= (from ?? 1) && x <= (to ?? decimal.MaxValue)); priceRanges.Add(new PriceRange() { From = from, To = to, Amount = amount }); } return(priceRanges); }