Exemple #1
0
        /// <summary>
        /// private method to retrieve risk properties from fullrisk object
        /// </summary>
        /// <param name="fullRisk"></param>
        /// <returns></returns>
        private List <RiskProperty> ProduceRiskModelProperties(FullRisk fullRisk)
        {
            List <RiskProperty> riskProperties = new List <RiskProperty>();

            foreach (RiskScoreTypes scoreType in Enum.GetValues(typeof(RiskScoreTypes)))
            {
                RiskScoreModel risk = fullRisk.GetRiskScore(scoreType);
                CreateRiskPropertiesFromRiskModel(fullRisk.Id, risk, ref riskProperties);
            }

            return(riskProperties);
        }
Exemple #2
0
        public IActionResult UpdateRisk(string rid, [FromBody] FullRisk fullRisk)
        {
            fullRisk.Id = Guid.Parse(rid);
            Risk risk = fullRisk.GetRisk();
            List <RiskProperty> riskProperties = ProduceRiskModelProperties(fullRisk);

            try
            {
                _riskService.UpdateProperties(riskProperties);
                _riskService.Update(risk);
                return(Ok(risk));
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }