Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Improve filter on customers and products
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericoregateiro committed Oct 13, 2017
1 parent 837e9f1 commit e4dabff
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Customer[] Customers
public string Filter
{
get { return filter; }
set { SetProperty(ref filter, value); }
set { SetProperty(ref filter, value, FilterCustomers); }
}

//SearchCommand
Expand Down
32 changes: 16 additions & 16 deletions src/SolRIA.SaftAnalyser/ViewModels/SaftProductsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ public Product Product
string filter;
public string Filter
{
get { return filter; }
set
{
SetProperty(ref filter, value);
get => filter;
set => SetProperty(ref filter, value, FilterProducts);
}

if (string.IsNullOrEmpty(filter))
Products = productsBack;
else
{
Products = (from c in productsBack
where !string.IsNullOrEmpty(c.ProductCode) && c.ProductCode.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.ProductDescription) && c.ProductDescription.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.ProductGroup) && c.ProductGroup.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.ProductNumberCode) && c.ProductNumberCode.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
c.ProductType.ToString().IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0
select c).ToArray();
}
private void FilterProducts()
{
if (string.IsNullOrEmpty(filter))
Products = productsBack;
else
{
Products = (from c in productsBack
where !string.IsNullOrEmpty(c.ProductCode) && c.ProductCode.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.ProductDescription) && c.ProductDescription.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.ProductGroup) && c.ProductGroup.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
!string.IsNullOrEmpty(c.ProductNumberCode) && c.ProductNumberCode.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0 ||
c.ProductType.ToString().IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0
select c).ToArray();
}
}

Expand Down

0 comments on commit e4dabff

Please sign in to comment.