Пример #1
0
        public void Process(ProjectHealthRiskThresholdUpdate @event)
        {
            //TODO: Assumes that project and health risk exists. Should be verified in BusinessValidator
            var projectHealthRisks = _projects.GetOne(p => p.Id == @event.ProjectId).HealthRisks;

            projectHealthRisks = projectHealthRisks.Select(r => r.HealthRiskId == @event.HealthRiskId
                    ? new ProjectHealthRisk
            {
                HealthRiskId = @event.HealthRiskId,
                Threshold    = @event.Threshold
            }
                    : r
                                                           ).ToArray();
            _projects.Update(p => p.Id == @event.ProjectId,
                             Builders <Project> .Update.Set(p => p.HealthRisks, projectHealthRisks));

            var project    = _projects.GetOne(p => p.Id == @event.ProjectId);
            var healthRisk = project.HealthRisks.FirstOrDefault(risk => risk.HealthRiskId == @event.HealthRiskId);

            _projectHealthRiskVersions.Append(project.Id, healthRisk, System.DateTimeOffset.UtcNow);
        }