public static bool ProductsFilter(ProviderProductModel providerProduct, ProviderProductFilterModel filter) { // The filters always are set to true, so we select the item if nothing is set, once a filter has a non-default value, it must cause a match, else it fails. if (providerProduct == null || filter == null) { return(false); } var output = Converters.EvaluateLocationFilter(filter.InGameFilter, filter.InArchiveFilter, providerProduct.InGame, providerProduct.InArchive); if (output) { output = Converters.EvaluateTextFilter(filter.ProviderFilter, providerProduct.Provider); } else { return(false); } if (output) { output = Converters.EvaluateTextFilter(filter.ProductFilter, providerProduct.Product); } return(output); }
public static List <ProviderProductModel> ApplyProductsFilter(List <ProviderProductModel> providerProducts, ProviderProductFilterModel filter) { return(providerProducts.Where(p => ProductsFilter(p, filter)).ToList()); }