public async Task <PagedResultDto <DM_ThietBiDto> > GetListGiamSatThietBiNew(GetDM_ThietBis input) { //Total Record var countQuery = _repository.GetAll() .WhereIf(!string.IsNullOrEmpty(input.Filter), p => p.NAME.Contains(input.Filter)) .WhereIf(input.IDDONVI != 0, x => x.TRAM.IDDONVI == input.IDDONVI) .WhereIf(input.IDTRAM != 0, x => x.IDTRAM == input.IDTRAM) ; var totalRecord = countQuery.Count(); //Record with filter & pager var result = _repository .GetAll() .WhereIf(!string.IsNullOrEmpty(input.Filter), p => p.NAME.Contains(input.Filter)) .WhereIf(input.IDDONVI != 0, x => x.TRAM.IDDONVI == input.IDDONVI) .WhereIf(input.IDTRAM != 0, x => x.IDTRAM == input.IDTRAM) .OrderByDescending(p => new { p.TRAM.IDDONVI, p.ConnectionID }) .PageBy(input).ToList() .MapTo <List <DM_ThietBiDto> >(); //for(var i =0; i< result.Count; i++) //{ // result[i].lsThongTin = _thongTin_ThietBiService.GetThongTinQuanLyByIdThietBi(result[i].Id); //} return(new PagedResultDto <DM_ThietBiDto>( totalRecord, result )); }
public async Task <PagedResultDto <DM_ThietBiDto> > GetDM_ThietBis(GetDM_ThietBis input) { //Total Record var countQuery = _repository.GetAll() .WhereIf(!string.IsNullOrEmpty(input.Filter), p => p.NAME.Contains(input.Filter)); var totalRecord = countQuery.Count(); //Record with filter & pager var result = _repository .GetAll() .WhereIf(!string.IsNullOrEmpty(input.Filter), p => p.NAME.Contains(input.Filter)) .OrderBy(p => p.NAME) .PageBy(input).ToList(); return(new PagedResultDto <DM_ThietBiDto>( totalRecord, result.MapTo <List <DM_ThietBiDto> >() )); }