(this IQueryable<Product> query, string? orderBy)
| 6 | public static class ProductExtensions |
| 7 | { |
| 8 | public static IQueryable<Product> Sort(this IQueryable<Product> query, string? orderBy) |
| 9 | { |
| 10 | query = orderBy switch |
| 11 | { |
| 12 | "price" => query.OrderBy(x => x.Price), |
| 13 | "priceDesc" => query.OrderByDescending(x => x.Price), |
| 14 | _ => query.OrderBy(x => x.Name) |
| 15 | }; |
| 16 | |
| 17 | return query; |
| 18 | } |
| 19 | |
| 20 | public static IQueryable<Product> Search(this IQueryable<Product> query, string? searchTerm) |
| 21 | { |