private List <ReportView> ConvertToReportView(List <Report> reports) { List <ReportView> reportView = new List <ReportView> (); if (reports != null && reports.Count > 0) { inspectionTransactionService = new InspectionTransactionService(AppDelegate.DatabaseContext); pathwayService = new PathwayService(AppDelegate.DatabaseContext); inspectionService = new InspectionService(AppDelegate.DatabaseContext); foreach (var report in reports) { if (reportView.Where(rv => rv.InspectionTransactionID == report.InspectionTransID).Count() <= 0) { var inspection = inspectionTransactionService.GetInspectionProjectID(report.InspectionTransID); if (inspection != null) { switch (inspection.PathwayTypeID) { case (0): inspection.PathwayTypeID = 1; break; case (1): inspection.PathwayTypeID = 2; break; case (2): inspection.PathwayTypeID = 3; break; default: break; } var pathway = pathwayService.GetPathway(inspection.PathwayTypeID); var inspectionType = inspectionService.GetInspection(Convert.ToInt32(inspection.InspectionID)); if ((report.ReportType.ToUpper() == ReportType.Pass.ToString().ToUpper()) || (report.ReportType.ToUpper() == ReportType.Fail.ToString().ToUpper())) { } else { report.ReportType = string.Empty; } reportView.Add(new ReportView() { AppID = inspection.ProjectID.ToString(), InspectionType = inspectionType.InspectionType, PathwayType = (pathway != null) ? pathway.PathwayDesc : "", ReportDesc = null, ReportType = report.ReportType, InspectionTransactionID = report.InspectionTransID, }); } } } } return(reportView); }