Esempio n. 1
0
 public void Append(Guid projectId, ProjectHealthRisk healthRisk, DateTimeOffset effectiveFromTime)
 {
     _collection.InsertOne(new ProjectHealthRiskVersion()
     {
         Id = Guid.NewGuid(),
         EffectiveFromTime = effectiveFromTime,
         HealthRisk        = healthRisk,
         ProjectId         = projectId
     });
 }
        public void Process(ProjectHealthRiskThresholdSet @event)
        {
            var project    = _projects.GetById(@event.ProjectId);
            var healthRisk = project.HealthRisks?.FirstOrDefault(v => v.HealthRiskId == @event.HealthRiskId);

            if (healthRisk == null)
            {
                healthRisk          = new ProjectHealthRisk();
                project.HealthRisks = (project.HealthRisks ?? new ProjectHealthRisk[0]).Union(new[] { healthRisk }).ToArray();
            }

            healthRisk.HealthRiskId = @event.HealthRiskId;
            healthRisk.Threshold    = @event.Threshold;
            _projects.Save(project);

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