public IPagedList <Award> Search(AwardSearchCriteria searchCriteria, PaginationOptions paginationOptions, WorkingUser user) { var query = _awardRepository.TableNoTracking; if (!string.IsNullOrEmpty(searchCriteria.Name)) { query = query.Where(x => x.Name.Contains(searchCriteria.Name)); } if (searchCriteria.Pv > 0) { query = query.Where(x => x.PV == searchCriteria.Pv); } if (string.IsNullOrEmpty(paginationOptions.Sort)) { query = query.OrderBy(x => x.Name); } else { query = query.SortBy(paginationOptions.SortExpression); } return(new PagedList <Award>(query, paginationOptions.PageIndex, paginationOptions.PageSize)); }
public JsonList <AwardModel> GetAll( [FromUri] AwardSearchCriteria searchCriteria, [FromUri] PaginationOptions options) { options = GetPaginationOptions(options); var model = new JsonList <AwardModel>(); if (searchCriteria.NoPaging) { var allAwards = _awardService.GetAll(); model.Data = allAwards.ToModelList <Award, AwardModel>(); model.TotalItems = allAwards.Count; } else { var searchData = _awardService.Search(searchCriteria, options, _workContext.User); model.Data = searchData.ToModelList <Award, AwardModel>(); model.TotalItems = searchData.TotalCount; } return(model); }