Example #1
0
        public bool IsWithinNumberOfHealthRisksLimit(Guid projectId)
        {
            var project       = _projects.GetById(projectId);
            var numberOfRisks = project.HealthRisks?.Length ?? 0;

            return(numberOfRisks < MaxNumberOfHealthRisksForProject);
        }
Example #2
0
        public void Process(ProjectCreated @event)
        {
            var project = _projects.GetById(@event.Id);

            project.Name = @event.Name;
            _projects.Save(project);
        }
        public void Process(ProjectCreated @event)
        {
            var project = _projects.GetById(@event.Id);

            project.NationalSociety    = _nationalSocieties.GetById(@event.NationalSocietyId);
            project.DataOwner          = _users.GetById(@event.DataOwnerId);
            project.Name               = @event.Name;
            project.SurveillanceContex = @event.SurveillanceContex;
            _projects.Save(project);
        }
        public void Process(ProjectUpdated projectUpdated)
        {
            var project = _projects.GetById(projectUpdated.Id);

            project.Name = projectUpdated.Name;
            _projects.Save(project);
        }
Example #5
0
        public IActionResult GetHealthRisks(Guid projectId)
        {
            var project = _projects.GetById(projectId);

            if (project != null)
            {
                var healthRisks = _healthRisks.GetAll();
                return(Ok(
                           healthRisks.Where(healthRisk => project.HealthRisks.Any(projectHealthRisk => projectHealthRisk.HealthRiskId == healthRisk.Id))
                           .Select(v => new
                {
                    HealthRiskId = v.Id,
                    v.Name,
                    project.HealthRisks.First(x => x.HealthRiskId == v.Id).Threshold
                })
                           ));
            }
            else
            {
                return(NotFound());
            }
        }
Example #6
0
        public void Process(ProjectUpdated @event)
        {
            //TODO Use UpdateOne instead
            var project = _projects.GetById(@event.Id);

            project.NationalSociety     = _nationalSocieties.GetById(@event.NationalSocietyId);
            project.DataOwner           = _users.GetById(@event.DataOwnerId);
            project.Name                = @event.Name;
            project.SurveillanceContext = (ProjectSurveillanceContext)@event.SurveillanceContext;
            project.SmsProxy            = @event.SmsProxy;
            _projects.Update(p => p.Id == @event.Id, Builders <Project> .Update.Combine(
                                 Builders <Project> .Update.Set(p => p.NationalSociety, _nationalSocieties.GetById(@event.NationalSocietyId)),
                                 Builders <Project> .Update.Set(p => p.DataOwner, _users.GetById(@event.DataOwnerId)),
                                 Builders <Project> .Update.Set(p => p.Name, @event.Name),
                                 Builders <Project> .Update.Set(p => p.SurveillanceContext, (ProjectSurveillanceContext)@event.SurveillanceContext),
                                 Builders <Project> .Update.Set(p => p.SmsProxy, @event.SmsProxy))
                             );
        }
Example #7
0
 public bool IsUserNotAVerifier(Guid projectId, Guid userId)
 {
     return(_projects.GetById(projectId).DataVerifiers.All(v => v.Id != userId));
 }
Example #8
0
 public Project Get(Guid id)
 {
     return(_projects.GetById(id));
 }
        private bool HealthRiskBelongsToProject(SetProjectHealthRiskThreshold arg)
        {
            var project = _projects.GetById(arg.ProjectId);

            return(project?.HealthRisks?.Any(v => v.HealthRiskId == arg.HealthRiskId) == true);
        }