Пример #1
0
        /// <summary>
        /// Assume args validated
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public async Task <string?> Execute(AuthorisationArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }


            var wf = await _WorkflowDb
                     .KeyReleaseWorkflowStates
                     .Include(x => x.Teks)
                     .FirstOrDefaultAsync(x => x.LabConfirmationId == args.LabConfirmationId);

            if (wf == null)
            {
                _Logger.LogError("KeyReleaseWorkflowState not found - LabConfirmationId:{LabConfirmationId}.", args.LabConfirmationId);
                return(null);
            }

            wf.AuthorisedByCaregiver = _DateTimeProvider.Snapshot;
            wf.LabConfirmationId     = null; //Clear from usable key range
            wf.DateOfSymptomsOnset   = args.DateOfSymptomsOnset;

            return(_NewPollTokenWriter.Execute(wf));
        }
Пример #2
0
        public async Task <IActionResult> Execute(LabVerifyArgs args)
        {
            if (!_LabVerifyArgsValidator.Validate(args))
            {
                return(new BadRequestResult());
            }

            var wf = await _DbContextProvider.KeyReleaseWorkflowStates
                     .Include(x => x.Teks)
                     .SingleOrDefaultAsync(x => x.PollToken == args.PollToken);

            if (wf == null)
            {
                _Logger.LogError("KeyReleaseWorkflowState not found - PollToken:{PollToken}.", args.PollToken);
                var error = new LabVerifyAuthorisationResponse {
                    Error = "Workflow not found.", Valid = false
                };
                return(new OkObjectResult(error));
            }

            var result = new LabVerifyAuthorisationResponse
            {
                PollToken = _Writer.Execute(wf),
                //NB wf.Teks.Count > 0 is only needed on the day the db change is applied and can be removed after
                Valid = wf.TeksTouched || wf.Teks.Count > 0
            };

            return(new OkObjectResult(result));
        }