public async Task <PopularResult <byte[]> > GetBytesAsync(ViolationQueryDto dto) { var result = new PopularResult <byte[]>(); var query = _violationRepository.Where(x => x.IsDelete == dto.IsDelete); var violations = await AsyncExecuter.ToListAsync(query); //转换为导出对象 var dtos = ObjectMapper.Map <List <ViolationEntity>, List <ViolationDto> >(violations); var stream = EPPlusHelper.GetMemoryStream(dtos); result.Success(stream.ToArray()); return(result); }
public async Task <PopularResult <PagedResultDto <ViolationDto> > > GetListAsync(ViolationQueryDto dto) { var result = new PopularResult <PagedResultDto <ViolationDto> >(); var countQuery = _violationRepository.Where(x => x.IsDelete == dto.IsDelete) .WhereIf(!dto.License.IsNullOrWhiteSpace(), violation => violation.Vehicle.License.Contains(dto.License)); var query = from m in countQuery.OrderBy(x => x.CreateTime).PageBy(dto.ToSkipCount(), dto.ToMaxResultCount()) join v in _vehicleRepository on m.VehicleId equals v.Id into cls from c in cls.DefaultIfEmpty() select new ViolationEntity(m.Id) { Fine = m.Fine, Indemnity = m.Indemnity, IsOutDanger = m.IsOutDanger, TookDate = m.TookDate, MaintenanceCost = m.MaintenanceCost, Vehicle = c, VehicleId = m.VehicleId, //IsDelete = m.IsDelete, CreateTime = m.CreateTime, Creator = m.Creator, Remark = m.Remark, }; var violations = await AsyncExecuter.ToListAsync(query); var totalCount = await AsyncExecuter.CountAsync(countQuery); var dtos = ObjectMapper.Map <List <ViolationEntity>, List <ViolationDto> >(violations); result.Success(new PagedResultDto <ViolationDto>(totalCount, dtos)); return(result); }
public async Task <PopularResult <byte[]> > GetExportAsync(ViolationQueryDto dto) { return(await _violationService.GetBytesAsync(dto)); }
public async Task <PopularResult <PagedResultDto <ViolationDto> > > GetPageAsync([FromQuery] ViolationQueryDto dto) { return(await _violationService.GetListAsync(dto)); }