public async Task <GetLocationsManagementDto> getLocationsManagement(int pageNo, string filter) { GetLocationsManagementDto oLocationsManagementDto = await _LocationService.getLocationsManagement(new GridInitialDto { recordCountPerPage = Setting.RECORD_COUNT_PAGE, pageNo = pageNo, filter = filter, userId = Setting.payloadDto.userId }); if (oLocationsManagementDto == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); } return(oLocationsManagementDto); }
public async Task <GetLocationsManagementDto> getLocationsManagement(GridInitialDto gridInitialDto) { if (gridInitialDto.pageNo < 1) { gridInitialDto.pageNo = 1; } var oLocationsManagementDto = new GetLocationsManagementDto(); IQueryable <Location> oLocations = _Locations.Include(r => r.country); if (!string.IsNullOrEmpty(gridInitialDto.filter)) { oLocations = oLocations .Where(w => w.locationName.Contains(gridInitialDto.filter) == true); } int totalRecordCount = await oLocations.AsNoTracking().CountAsync(); if (totalRecordCount != 0) { int totalPages = (int)Math.Ceiling((double)totalRecordCount / gridInitialDto.recordCountPerPage); if (gridInitialDto.pageNo > totalPages) { gridInitialDto.pageNo = totalPages; } var intFrom = (gridInitialDto.pageNo - 1) * gridInitialDto.recordCountPerPage; oLocationsManagementDto.getLocationsDto = Mapper.Map <IEnumerable <Location>, List <GetLocationsDto> >(await oLocations.GetPageRecords(gridInitialDto.pageNo, gridInitialDto.recordCountPerPage).ToListAsync()); oLocationsManagementDto.currentPage = gridInitialDto.pageNo; oLocationsManagementDto.totalRecordCount = totalRecordCount; } return(oLocationsManagementDto); }