public async Task <JsonResult> GetDeviceListPaged(GetDeviceListPagedInput input) { input.UserId = AbpSession.GetUserId(); var result = await _deviceAppService.GetDeviceListPagedAsync(input); return(Json(result, JsonRequestBehavior.AllowGet)); }
public async Task <PagedResultOutput <GetDeviceListDto> > GetDeviceListPagedAsync(GetDeviceListPagedInput input) { var query = _deviceRepository.GetAll() .Include(p => p.Tenant) .Include(p => p.User) .Include(p => p.DeviceType) .WhereIf(!input.SearchText.IsNullOrEmpty(), p => p.BName.Contains(input.SearchText) || p.BDscription.Contains(input.SearchText) || p.BSimNo.Contains(input.SearchText) || p.BNo.Contains(input.SearchText)) .WhereIf(input.UserId.HasValue, p => p.UserId == input.UserId.Value) .WhereIf(input.DeviceTypeId.HasValue, p => p.BDeviceTypeId == input.DeviceTypeId.Value) .WhereIf(input.IsLocated.HasValue, p => p.GIsLocated) .WhereIfDynamic(input.StartTime.HasValue, input.SearchTime + ">", input.StartTime) .WhereIfDynamic(input.EndTime.HasValue, input.SearchTime + "<", input.EndTime); var count = await query.CountAsync(); var list = await query.OrderBy(input).PageBy(input).ToListAsync(); return(new PagedResultOutput <GetDeviceListDto>(count, list.MapTo <List <GetDeviceListDto> >())); }