public decimal GetScoreByReportId(int id) { var totalCvssScore = 0m; foreach (var reportLine in _reportLinesRepository.SelectListByReportId(id)) { var ossIndexId = _ossIndexRepository .Select(reportLine.OssIndexId) .Id; totalCvssScore += GetScoreByOssIndexId(ossIndexId); } return(totalCvssScore); }
// GET: Report/ReportLines/5 public IActionResult ReportLines(int id) { var report = _reportRepository.Select(id); var project = _projectRepository.Select(report.ProjectId); var reportLineViewModel = new ReportLineViewModel { ProjectName = project.ProjectName, OssIndexs = new List <OssIndexViewModel>() }; foreach (var reportLine in _reportLinesRepository.SelectListByReportId(report.Id)) { var ossIndex = _ossIndexRepository.Select(reportLine.OssIndexId); var component = _componentRepository.Select(ossIndex.ComponentId); var score = _scoreService.GetScoreByOssIndexId(reportLine.OssIndexId); Enum.TryParse(ossIndex.HttpStatus.ToString(), out HttpStatusCode httpStatusCode); reportLineViewModel.OssIndexs.Add(new OssIndexViewModel() { Id = reportLine.OssIndexId, ComponentName = component.Name, Score = score, ScoreFieldClass = _scoreClassService.SetScoreFieldClass(score), Status = httpStatusCode.ToString() }); } HttpContext.Session.SetString(SessionConstants.ProjectName, project.ProjectName); HttpContext.Session.SetInt32(SessionConstants.ProjectId, project.Id); HttpContext.Session.SetInt32(SessionConstants.ReportId, id); SetTopNavSelected(); ViewData["Breadcrumbs"] = _breadcrumbService.GetReportLines(project.ProjectName, project.Id); return(View(reportLineViewModel)); }
private List <int> GetHttpStatusListByProjectId(int id) { var httpStatusList = new List <int>(); var lastReportId = _reportRepository .SelectByProjectId(id) .OrderByDescending(x => x.InsertDate) .First() .Id; foreach (var reportLine in _reportLinesRepository.SelectListByReportId(id)) { var ossIndex = _ossIndexRepository .Select(reportLine.OssIndexId); if (!httpStatusList.Contains(ossIndex.HttpStatus)) { httpStatusList.Add(ossIndex.HttpStatus); } } return(httpStatusList); }