(this IQueryable<Product> query, string? searchTerm)
| 18 | } |
| 19 | |
| 20 | public static IQueryable<Product> Search(this IQueryable<Product> query, string? searchTerm) |
| 21 | { |
| 22 | if (string.IsNullOrEmpty(searchTerm)) return query; |
| 23 | |
| 24 | var lowerCaseSearchTerm = searchTerm.Trim().ToLower(); |
| 25 | |
| 26 | return query.Where(x => x.Name.ToLower().Contains(lowerCaseSearchTerm)); |
| 27 | } |
| 28 | |
| 29 | public static IQueryable<Product> Filter(this IQueryable<Product> query, |
| 30 | string? brands, string? types) { |