Exemple #1
0
        public async Task <IActionResult> Create([FromBody] RiskModel model)
        {
            var project = await _projectRepository.GetAsync(model.ProjectId);

            if (project == null)
            {
                return(NotFound("Project not found"));
            }

            var riskStatus = await _riskStatusRepository.FindAsync(_ => _.Title == model.Status);

            if (riskStatus == null)
            {
                return(NotFound("Risk Status not found"));
            }

            var risk = await _riskRepository
                       .AddAsyn(new Risk()
            {
                Title               = model.Title,
                Description         = model.Description,
                DateIdentified      = model.DateIdentified,
                MostLikelyEstimate  = model.MostLikelyEstimate,
                OptimisticEstimate  = model.OptimisticEstimate,
                PessimisticEstimate = model.PessimisticEstimate,
                RiskStatus          = riskStatus,
                Project             = project
            })
                       .ConfigureAwait(false);

            return(CreatedAtRoute("GetRisk", new { id = risk.Id }, risk));
        }