public static RiskCalculationContentEntity ToEntity(this RiskCalculationConfigArgs args)
        {
            var content = new RiskCalculationConfigContent
            {
                MinimumRiskScore = args.MinimumRiskScore,
                Attenuation      = new WeightingContent {
                    Weight = args.Attenuation.Weight, LevelValues = args.Attenuation.LevelValues
                },
                DaysSinceLastExposure = new WeightingContent {
                    Weight = args.DaysSinceLastExposure.Weight, LevelValues = args.DaysSinceLastExposure.LevelValues
                },
                DurationLevelValues = new WeightingContent {
                    Weight = args.DurationLevelValues.Weight, LevelValues = args.DurationLevelValues.LevelValues
                },
                TransmissionRisk = new WeightingContent {
                    Weight = args.TransmissionRisk.Weight, LevelValues = args.TransmissionRisk.LevelValues
                },
            };

            return(new RiskCalculationContentEntity
            {
                Release = args.Release,
                Content = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(content))
            });
        }
        private async Task Write(RiskCalculationConfigArgs a4)
        {
            var e4 = new RiskCalculationContentEntity
            {
                Release = a4.Release
            };
            await _Formatter.Fill(e4, a4.ToContent());

            await _DbContextProvider.AddAsync(e4);
        }
 public static RiskCalculationConfigContent ToContent(this RiskCalculationConfigArgs args)
 => new RiskCalculationConfigContent
 {
     MinimumRiskScore                 = args.MinimumRiskScore,
     DaysSinceLastExposureScores​     = args.DaysSinceLastExposureScores​,
     AttenuationScores​               = args.AttenuationScores​,
     DurationAtAttenuationThresholds​ = args.DurationAtAttenuationThresholds​,
     DurationScores          = args.DurationScores,
     TransmissionRiskScores​ = args.TransmissionRiskScores​
 };
Beispiel #4
0
        public async Task Execute()
        {
            _DbContextProvider.Current.Database.EnsureCreated();
            using var tx = _DbContextProvider.Current.Database.BeginTransaction();

            var e0 = new MobileDeviceRivmAdviceArgs
            {
                Release = new DateTime(2020, 1, 1),
                Text    = new[]
                {
                    new LocalizableTextArgs
                    {
                        Locale = "en-GB", IsolationAdviceShort = "1st", IsolationAdviceLong = "First",
                    },
                    new LocalizableTextArgs
                    {
                        Locale = "nl-nl", IsolationAdviceShort = "1e", IsolationAdviceLong = "Eerste",
                    }
                }
            }.ToEntity();

            e0.PublishingId = _PublishingIdCreator.Create(e0);
            await _DbContextProvider.Current.AddAsync(e0);

            var e1 = new MobileDeviceRivmAdviceArgs
            {
                Release             = new DateTime(2020, 5, 1),
                IsolationPeriodDays = 10,
                ObservedTemporaryExposureKeyRetentionDays = 14,
                TemporaryExposureKeyRetentionDays         = 15,
                Text = new[]
                {
                    new LocalizableTextArgs
                    {
                        Locale = "en-GB", IsolationAdviceShort = "Stay the hell indoors for {0} day!!!", IsolationAdviceLong = "Something hmtl, zipped",
                    },
                    new LocalizableTextArgs
                    {
                        Locale = "nl-nl", IsolationAdviceShort = "Verklaar de hel binnenshuis", IsolationAdviceLong = "Verklaar de hel binnenshuis but longer.",
                    }
                }
            }.ToEntity();

            e1.PublishingId = _PublishingIdCreator.Create(e1);
            await _DbContextProvider.Current.AddAsync(e1);

            var e2 = new MobileDeviceRivmAdviceArgs
            {
                Release = new DateTime(2021, 1, 1),
                Text    = new LocalizableTextArgs[0]
            }.ToEntity();

            e2.PublishingId = _PublishingIdCreator.Create(e2);
            await _DbContextProvider.Current.AddAsync(e2);

            //TODO something more realistic
            var e4 = new RiskCalculationConfigArgs
            {
                Release          = new DateTime(2020, 5, 1),
                MinimumRiskScore = 4,
                Attenuation      = new WeightingArgs {
                    Weight = 30, LevelValues = new[] { 1 }
                },
                DaysSinceLastExposure = new WeightingArgs {
                    Weight = 40, LevelValues = new[] { 1, 2, 3, 4 }
                },
                DurationLevelValues = new WeightingArgs {
                    Weight = 50, LevelValues = new[] { 10, 2, 3, 4, 5 }
                },
                TransmissionRisk = new WeightingArgs {
                    Weight = 60, LevelValues = new[] { 10, 100, 1000 }
                },
            }.ToEntity();

            e4.PublishingId = _PublishingIdCreator.Create(e4);
            await _DbContextProvider.Current.AddAsync(e4);

            tx.Commit();
        }
Beispiel #5
0
 public bool Valid(RiskCalculationConfigArgs args)
 {
     return(true); //TODO obviously...
 }
 public async Task <IActionResult> Post([FromBody] RiskCalculationConfigArgs args, [FromServices] HttpPostRiskCalculationConfigCommand command)
 {
     return(await command.Execute(args));
 }