public List <PipeReportDTO> GetBySearchFilters([FromBody] PipeReportFilterDTO pipeReportFilterDTO) { return(_PipeReportService.GetBySearchFilters(pipeReportFilterDTO)); }
public List <PipeReportDTO> GetBySearchFilters(PipeReportFilterDTO pipeReportFilterDTO) { List <PipeReportDTO> reportList = new List <PipeReportDTO>(); IQueryable <PipeReportDTO> query = (from p in _unitOfWork.PipeReport.GenerateEntityAsIQueryable() join m in _context.PipeMaster on p.PipeMasterID equals m.ID join l in _context.Plant on p.PlantCode equals l.Code select new PipeReportDTO { ID = p.ID, EquipmentNo = p.EquipmentNo, ReportNo = p.ReportNo, PipeMasterID = p.PipeMasterID, FromTo = p.FromTo, FluidCode = m.FluidCode, ParentPlantCode = l.ParentPlant.Code, PlantCode = m.PlantCode, OverallCondition = p.OverallCondition, OverallStatus = p.OverallStatus, ConsequenceRank = p.ConsequenceRank, InspectionYear = p.InspectionYear, DefectCode = p.DefectCode, NextFollowUpDate = p.NextFollowUpDate, ResultedInto = p.ResultedInto, CreatedBy = p.CreatedBy, CreatedDate = p.CreatedDate, ModifiedBy = p.ModifiedBy, ModifiedDate = p.ModifiedDate }); if (pipeReportFilterDTO != null) { if (!string.IsNullOrWhiteSpace(pipeReportFilterDTO.EquipmentNo)) { query = (from re in query where re.EquipmentNo == pipeReportFilterDTO.EquipmentNo select re); } if (!string.IsNullOrWhiteSpace(pipeReportFilterDTO.ReportNo)) { query = (from re in query where re.ReportNo == pipeReportFilterDTO.ReportNo select re); } if (!string.IsNullOrWhiteSpace(pipeReportFilterDTO.PlantCode)) { query = (from re in query where re.PlantCode == pipeReportFilterDTO.PlantCode select re); } if (!string.IsNullOrWhiteSpace(pipeReportFilterDTO.FluidCode)) { query = (from re in query where re.FluidCode == pipeReportFilterDTO.FluidCode select re); } if (!string.IsNullOrWhiteSpace(pipeReportFilterDTO.ParentPlantCode)) { query = (from re in query where re.ParentPlantCode == pipeReportFilterDTO.ParentPlantCode select re); } if (!string.IsNullOrWhiteSpace(pipeReportFilterDTO.DefectCode)) { query = (from re in query where re.DefectCode == pipeReportFilterDTO.DefectCode select re); } if (!string.IsNullOrWhiteSpace(pipeReportFilterDTO.Status)) { query = (from re in query where re.OverallStatus == pipeReportFilterDTO.Status select re); } if (pipeReportFilterDTO.InspectionYear.HasValue) { query = (from re in query where re.InspectionYear == pipeReportFilterDTO.InspectionYear select re); } reportList = query.OrderBy(p => p.ReportNo).ToList(); } return(reportList); }