public PipeReportResponseDTO GetByReportNo(string ReportNo) { PipeReportResponseDTO result = new PipeReportResponseDTO(); try { result = _PipeReportService.GetByReportNo(ReportNo); _logger.LogDebug("Result returned"); } catch (Exception exception) { _logger.LogError(exception, ""); } return(result); }
public PipeReportResponseDTO GetByReportNo(string ReportNo) { PipeReportResponseDTO response = new PipeReportResponseDTO(); try { PipeReport pipeReport = (from s in _unitOfWork.PipeReport.GenerateEntityAsIQueryable() where s.ReportNo == ReportNo select s).FirstOrDefault(); if (pipeReport != null) { // Pipe Report response.PipeReport = _mapper.Map <PipeReportDTO>(pipeReport); // Inspection Confidence List <InspectionConfidence> inspectionConfidenceList = (from s in _unitOfWork.InspectionConfidence.GenerateEntityAsIQueryable() where s.PipeReportID == pipeReport.ID select s).ToList(); if (inspectionConfidenceList != null && inspectionConfidenceList.Count > 0) { response.InspectionConfidenceList = new List <InspectionConfidenceDTO>(); foreach (InspectionConfidence confidence in inspectionConfidenceList) { InspectionConfidenceDTO inspectionConfidenceDTO = _mapper.Map <InspectionConfidenceDTO>(confidence); response.InspectionConfidenceList.Add(inspectionConfidenceDTO); } } // Inspection Observation List <InspectionObservation> inspectionObservationList = (from s in _unitOfWork.InspectionObservation.GenerateEntityAsIQueryable() where s.PipeReportID == pipeReport.ID select s).ToList(); if (inspectionObservationList != null && inspectionObservationList.Count > 0) { response.InspectionObservationList = new List <InspectionObservationDTO>(); foreach (InspectionObservation observation in inspectionObservationList) { InspectionObservationDTO inspectionObservationDTO = _mapper.Map <InspectionObservationDTO>(observation); response.InspectionObservationList.Add(inspectionObservationDTO); } } // Inspection Program List <InspectionProgram> inspectionProgramList = (from s in _unitOfWork.InspectionProgram.GenerateEntityAsIQueryable() where s.PipeReportID == pipeReport.ID select s).ToList(); if (inspectionProgramList != null && inspectionProgramList.Count > 0) { response.InspectionProgramList = new List <InspectionProgramDTO>(); foreach (InspectionProgram program in inspectionProgramList) { InspectionProgramDTO inspectionProgramDTO = _mapper.Map <InspectionProgramDTO>(program); response.InspectionProgramList.Add(inspectionProgramDTO); } } // Inspection Document List <InspectionDocument> inspectionDocumentList = (from s in _unitOfWork.InspectionDocument.GenerateEntityAsIQueryable() where s.PipeReportID == pipeReport.ID select s).ToList(); if (inspectionDocumentList != null && inspectionDocumentList.Count > 0) { response.InspectionDocumentList = new List <InspectionDocumentDTO>(); foreach (InspectionDocument document in inspectionDocumentList) { InspectionDocumentDTO inspectionDocumentDTO = _mapper.Map <InspectionDocumentDTO>(document); response.InspectionDocumentList.Add(inspectionDocumentDTO); } } // Inspection Recommendation List <InspectionRecommendation> inspectionRecommendationList = (from s in _unitOfWork.InspectionRecommendation.GenerateEntityAsIQueryable() where s.PipeReportID == pipeReport.ID select s).ToList(); if (inspectionRecommendationList != null && inspectionRecommendationList.Count > 0) { response.InspectionRecommendationList = new List <InspectionRecommendationDTO>(); foreach (InspectionRecommendation recommendation in inspectionRecommendationList) { InspectionRecommendationDTO inspectionRecommendationDTO = _mapper.Map <InspectionRecommendationDTO>(recommendation); response.InspectionRecommendationList.Add(inspectionRecommendationDTO); } } // Inspection Distribution List <InspectionDistribution> inspectionDistributionList = (from s in _unitOfWork.InspectionDistribution.GenerateEntityAsIQueryable() where s.PipeReportID == pipeReport.ID select s).ToList(); if (inspectionDistributionList != null && inspectionDistributionList.Count > 0) { response.InspectionDistributionList = new List <InspectionDistributionDTO>(); foreach (InspectionDistribution distribution in inspectionDistributionList) { InspectionDistributionDTO inspectionDistributionDTO = _mapper.Map <InspectionDistributionDTO>(distribution); response.InspectionDistributionList.Add(inspectionDistributionDTO); } } // TML List <TML> TMLList = (from s in _unitOfWork.TML.GenerateEntityAsIQueryable() where s.PipeReportID == pipeReport.ID select s).ToList(); if (TMLList != null && TMLList.Count > 0) { response.TMLList = new List <TMLDTO>(); foreach (TML tml in TMLList) { TMLDTO TMLDTO = _mapper.Map <TMLDTO>(tml); response.TMLList.Add(TMLDTO); } } response.ReportNo = pipeReport.ReportNo; response.Status = true; response.StatusMessage = ""; response.StatusCode = 200; return(response); } else { return(new PipeReportResponseDTO { Status = false, StatusMessage = "Report donot exist - " + ReportNo, StatusCode = 200 }); } } catch (Exception ex) { return(new PipeReportResponseDTO() { ReportNo = ReportNo, Status = false, StatusMessage = ex.Message, StatusCode = 200 }); } }