public IHttpActionResult RiskMap(Guid id, RiskMap update) {
      RiskMap riskMap = repo().UpdateRiskMap(id, update);
      if (riskMap == null)
        return NotFound();

      return Ok(riskMap);
    } // RiskMap
    public IHttpActionResult RiskMap(Guid id) {
      RiskMap riskMap = repo().RiskMap(id);
      if (riskMap == null)
        return NotFound();

      return Ok(riskMap);
    } // RiskMap
    public IHttpActionResult RiskMap(RiskMap newRiskMap) {
      RiskMap riskMap = repo().CreateRiskMap(newRiskMap);
      if (riskMap == null)
        return NotFound();

      return Ok(riskMap);
    } // RiskMap
Example #4
0
        } // buildCSV

        private static IList <CategoryRow> buildCatRows(
            string themeName,
            RiskMap riskMap,
            IDictionary <Guid, ResolutionRow> report)
        {
            var cats = new List <CategoryRow>();

            foreach (var category in riskMap.AllCategories())
            {
                var catRisks = riskMap.Risks.
                               Where(r => r.Theme == themeName).
                               Where(r => r.Category == category);

                if (catRisks.Count() == 0)
                {
                    continue;
                }

                var risks = catRisks.
                            OrderBy(r => r.Grouping).
                            ThenBy(r => riskScoreSort(r)).
                            Select(r => report[r.Id]).
                            ToList();

                cats.Add(new CategoryRow(category, risks));
            } // foreach
            return(cats);
        }     // buildCatRows
    public IHttpActionResult RiskMap(string name, RiskMap update) {
      RiskMap riskMap = repo().UpdateRiskMap(name, update);
      if (riskMap == null)
        return NotFound();

      return Ok(riskMap);
    } // RiskMap
Example #6
0
        public static ReportData <ThemeRow> build(Guid orgId, Guid projId, Guid?locId, DateTime?startDate, DateTime?endDate)
        {
            ProjectOrganisationRepository poRepo = new ProjectOrganisationRepository();
            RiskMapRepository             rmRepo = new RiskMapRepository(orgId);
            ClientRepository clientRepo          = new ClientRepository();

            ProjectOrganisation po      = poRepo.Get(orgId);
            Project             project = poRepo.FindProject(orgId, projId);
            RiskMap             riskMap = rmRepo.RiskMap(project.RiskFramework);
            IList <ClientData>  clients = clientRepo.ProjectClientData(projId, locId);

            IDictionary <Guid, ResolutionRow> report = new Dictionary <Guid, ResolutionRow>();

            foreach (var risk in riskMap.Risks)
            {
                report.Add(risk.Id, new ResolutionRow(risk));
            }

            HashSet <Guid> clientsSeen = new HashSet <Guid>();

            foreach (var client in clients)
            {
                if (client.RiskAssessments == null || client.RiskAssessments.Count == 0)
                {
                    continue;
                }
                foreach (var rad in client.RiskAssessments)
                {
                    if (Reports.outOfBounds(rad.Timestamp, startDate, endDate))
                    {
                        continue;
                    }
                    foreach (var riskId in rad.Risks())
                    {
                        ResolutionRow row = report[riskId];
                        row.Open(client);
                    }
                    foreach (var riskId in rad.ResolvedRisks())
                    {
                        ResolutionRow row = report[riskId];
                        row.Close(client);
                    }

                    clientsSeen.Add(client.Id);
                } // foreach RiskAssessment
            }     // foreach Client

            IList <ThemeRow> themes = new List <ThemeRow>();

            foreach (var theme in riskMap.AllThemes())
            {
                var catRows = buildCatRows(theme, riskMap, report);
                themes.Add(new ThemeRow(theme, catRows));
            } // foreach

            ReportData <ThemeRow> reportData =
                new ReportData <ThemeRow>(themes);

            reportData.Put("clientCount", clientsSeen.Count.ToString());
            reportData.Put("csvurl", Reports.csvUrl("resolution", orgId, projId, locId, startDate, endDate));

            return(reportData);
        } // resolutionReport