public PagedResultModel <LPCReportModel> GetLPCReports(LPCReportRequest request) { var predicate = PredicateBuilder.True <LPCReport>(); if (!string.IsNullOrEmpty(request.Borough)) { predicate = predicate.And(x => x.Borough == request.Borough); } if (!string.IsNullOrEmpty(request.ObjectType)) { predicate = predicate.And(x => x.ObjectType == request.ObjectType); } var sortModel = new SortModel { SortColumn = !string.IsNullOrEmpty(request.SortColumn) ? request.SortColumn : null, SortOrder = !string.IsNullOrEmpty(request.SortOrder) ? request.SortOrder : null }; var sortingList = new List <SortModel>(); sortingList.Add(sortModel); int totalCount = _lpcReportRepository.FindBy(predicate).Count(); var results = _lpcReportRepository .GetPage(predicate, request.PageSize * (request.Page - 1), request.PageSize, sortingList); var modelData = Mapper.Map <IEnumerable <LPCReport>, IEnumerable <LPCReportModel> >(results).ToList(); var pagedResult = new PagedResultModel <LPCReportModel> { Total = totalCount, Page = request.Page, Limit = request.PageSize, Results = modelData, }; return(pagedResult); }
public void Can_Get_Paging_List() { //int count = 0; var request = new LPCReportRequest { PageSize = 20, Page = 1, }; var sortingList = new List <SortModel>() { new SortModel { SortColumn = "name", SortOrder = "asc" } }; var results = _lpcReportRepository.GetPage(request.Page, request.PageSize, sortingList).ToList(); Assert.Equal(request.PageSize, results.Count); }
//[Fact] public void Can_Get_Filtered_Paging_List() { var predicate = PredicateBuilder.True <LPCReport>(); var request = new LPCReportRequest() { PageSize = 20, Page = 1, }; var sortModel = new SortModel { SortColumn = !string.IsNullOrEmpty(request.SortColumn) ? request.SortColumn : null, SortOrder = !string.IsNullOrEmpty(request.SortOrder) ? request.SortOrder : null }; var sortingList = new List <SortModel>(); sortingList.Add(sortModel); var results = lpcReportRepository .GetPage(predicate, request.PageSize * (request.Page - 1), request.PageSize, sortingList); Assert.NotNull(results); }