public static List<RadioRow> FilterPackages(Controller controller, AtomiaBillingPublicService atomiaBillingPublicService, Guid accountId, Guid resellerId, string currencyCode, string countryCode, string filterValue)
{
string languageCode = null;
if (controller.HttpContext.Session != null
&& controller.HttpContext.Session["SessionAccountLanguages"] != null)
{
AtomiaCultureInfo atomiaCultureInfo =
(AtomiaCultureInfo)controller.HttpContext.Session["SessionAccountLanguages"];
languageCode = atomiaCultureInfo.Language;
}
List<RadioRow> packages = OrderModel.FetchPackagesData(controller, resellerId, null, accountId, currencyCode, countryCode, languageCode).ToList();
if (!string.IsNullOrEmpty(filterValue))
{
// get all packages from the config
IList<Product> packageProducts = GetProductProvider().GetShopProducts(resellerId, null, accountId, countryCode);
packages = packages.Where(rr =>
{
Product item = packageProducts.FirstOrDefault(p => p.ArticleNumber == rr.productId);
if (item == null)
{
return false;
}
string value;
if (item.Properties.TryGetValue("groups", out value))
{
return value
.ToString()
.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
.ToList()
.Exists(v => v == filterValue);
}
return false;
}).ToList();
}
return packages;
}