// ..................................................................................Get Grid Data..................................................................... public async Task <GridData> GetGridData(QueryParams queryParams) { await queryParams.Init(context); List <QueryResult> products = await QueryProducts(queryParams); QueryBuilder queryBuilder = new QueryBuilder(queryParams); int totalProducts = products.Count(); return(new GridData { Products = products .OrderBy(queryBuilder) .Select(queryBuilder) .Skip((int)((queryParams.Page - 1) * queryParams.Limit)) .Take((int)queryParams.Limit) .ToList(), TotalProducts = totalProducts, PageCount = Math.Ceiling(totalProducts / queryParams.Limit), Filters = await GetProductFilters(products, queryParams), ProductCountStart = ((queryParams.Page - 1) * queryParams.Limit) + 1, ProductCountEnd = Math.Min(queryParams.Page * queryParams.Limit, totalProducts), SortOptions = queryParams.Search != null && queryParams.Search != string.Empty ? queryBuilder.GetSearchSortOptions() : queryBuilder.GetBrowseSortOptions() }); }
// ..................................................................................Get Product Group..................................................................... public async Task <List <QueriedProduct> > GetProductGroup(QueryParams queryParams) { await queryParams.Init(context); List <QueryResult> products = await QueryProducts(queryParams); QueryBuilder queryBuilder = new QueryBuilder(queryParams); return(products .OrderBy(queryBuilder) .Select(queryBuilder) .Take((int)queryParams.Limit) .ToList()); }