/// <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)); }
public string[] Validate(AuthorisationArgs args) { if (args == null) { return new [] { "Args is null." } } ; //Should be a date. args.DateOfSymptomsOnset = args.DateOfSymptomsOnset.Date; var errors = new List <string>(); errors.AddRange(_LabConfirmationIdService.Validate(args.LabConfirmationId)); // TODO check SymptonsOnDate is valid date in !past! // TODO setting if (_DateTimeProvider.Snapshot.Date.AddDays(-30) > args.DateOfSymptomsOnset.Date || args.DateOfSymptomsOnset.Date > _DateTimeProvider.Snapshot.Date) { errors.Add($"Date of symptoms onset out of range - {args.DateOfSymptomsOnset}."); } return(errors.ToArray()); } }
public async Task <IActionResult> Execute(AuthorisationArgs args) { await _AuthorisationWriter.Execute(args); _DbContextProvider.SaveAndCommit(); return(new OkObjectResult(new AuthorisationResponse { Valid = true })); }
public async Task <IActionResult> Execute(AuthorisationArgs args) { if (_AuthorisationWriter.Validate(args)) { return(new BadRequestResult()); } var result = await _AuthorisationWriter.Execute(args); return(new OkObjectResult(result)); }
public async Task <IActionResult> Execute(AuthorisationArgs args) { if (_Logger.LogValidationMessages(_AuthorisationArgsValidator.Validate(args))) { return(new BadRequestResult()); } var newPollToken = await _AuthorisationWriter.Execute(args); var response = new AuthorisationResponse { Valid = newPollToken != null, PollToken = newPollToken }; return(new OkObjectResult(response)); }
public Task Execute(AuthorisationArgs args) { var e = _DbContextProvider .KeyReleaseWorkflowStates .SingleOrDefault(x => x.LabConfirmationId == args.LabConfirmationId); if (e == null) { return(Task.CompletedTask); } e.AuthorisedByCaregiver = true; e.DateOfSymptomsOnset = args.DateOfSymptomsOnset; if (e.Keys != null && e.Keys.Any()) { e.Authorised = true; } _DbContextProvider.KeyReleaseWorkflowStates.Update(e); return(Task.CompletedTask); }