Example #1
0
        public async Task Execute(WorkflowArgs args)
        {
            var e = args.ToEntity();

            e.Created = _UtcDateTimeProvider.Now();
            await _DbContextProvider.Current.AddAsync(e);
        }
Example #2
0
        public IActionResult Execute(WorkflowArgs args)
        {
            if (!_WorkflowValidator.Validate(args))
            {
                return(new BadRequestResult());
            }

            using (var tx = _DbContextProvider.BeginTransaction())
            {
                _WorkflowDbInsertCommand.Execute(args).GetAwaiter().GetResult();
                _DbContextProvider.Current.SaveChanges();
                tx.Commit();
            }

            return(new OkResult());
        }
        public bool Validate(WorkflowArgs args)
        {
            if (args == null)
            {
                return(false);
            }

            if (!_AuthorisationTokenValidator.IsValid(args.Token))
            {
                return(false);
            }

            if (_Config.WorkflowKeyCountMin > args.Items.Length ||
                args.Items.Length > _Config.WorkflowKeyCountMax)
            {
                return(false);
            }

            return(args.Items.All(_TemporaryExposureKeyValidator.Valid));
        }