public async Task <GetCustomersManagementDto> getCustomersManagement(int pageNo, string filter) { GetCustomersManagementDto oGetCustomersManagementDto = await _CustomerService.getCustomersManagement(new GridInitialDto { recordCountPerPage = Setting.RECORD_COUNT_PAGE, pageNo = pageNo, filter = filter, userId = Setting.payloadDto.userId }); if (oGetCustomersManagementDto == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); } return(oGetCustomersManagementDto); }
public async Task <GetCustomersManagementDto> getCustomersManagement(GridInitialDto gridInitialDto) { int pageNo = gridInitialDto.pageNo; if (gridInitialDto.pageNo < 1) { pageNo = 1; } IQueryable <Customer> oCustomers = _Customers.AsQueryable(); if (!string.IsNullOrEmpty(gridInitialDto.filter)) { oCustomers = oCustomers .Where(w => w.fullName.Contains(gridInitialDto.filter) == true); } int totalRecordCount = await oCustomers.AsNoTracking().CountAsync(); GetCustomersManagementDto oGetCustomersManagementDto = new GetCustomersManagementDto(); if (totalRecordCount != 0) { int totalPages = (int)Math.Ceiling((double)totalRecordCount / gridInitialDto.recordCountPerPage); if (pageNo > totalPages) { pageNo = totalPages; } oGetCustomersManagementDto.getCustomersDto = Mapper.Map <IEnumerable <Customer>, List <GetCustomersDto> > (await oCustomers.GetPageRecords(pageNo, gridInitialDto.recordCountPerPage).ToListAsync()); oGetCustomersManagementDto.currentPage = pageNo; oGetCustomersManagementDto.totalRecordCount = totalRecordCount; } return(oGetCustomersManagementDto); }