public async Task Execute(ReleaseTeksArgs args)
        {
            var wf = _DbContextProvider
                     .KeyReleaseWorkflowStates
                     .FirstOrDefault(x => x.BucketId == args.BucketID);

            if (wf == null)
            {
                _Logger.LogInformation($"Workflow with bucketId {args.BucketID} not found.");
                return;
            }

            var entities = args.Keys.ToEntities();

            foreach (var e in entities)
            {
                e.Owner = wf;
            }

            if (wf.AuthorisedByCaregiver)
            {
                wf.Authorised = true;
            }

            await _DbContextProvider.TemporaryExposureKeys.AddRangeAsync(entities);
        }
        public bool Validate(ReleaseTeksArgs args, KeyReleaseWorkflowState workflow)
        {
            if (args == null)
            {
                return(false);
            }

            if (workflow.ValidUntil.AddMinutes(_Config.GracePeriodMinutes) <= _DateTimeProvider.Now()) //30 minutes grace period
            {
                _Logger.LogWarning($"Workflow is not valid anymore: {args.BucketId}");
                return(false);
            }

            if (_Config.TemporaryExposureKeyCountMin > args.Keys.Length || args.Keys.Length > _Config.TemporaryExposureKeyCountMax)
            {
                _Logger.LogWarning($"Invalid number of keys: {args.BucketId}");
                return(false);
            }

            if (!args.Keys.All(_TemporaryExposureKeyValidator.Valid))
            {
                _Logger.LogWarning($"One or more keys not valid: {args.BucketId}");
                return(false);
            }

            return(true);
        }