public async Task PatchDataLocks(long providerId, long apprenticeshipId, DataLockTriageSubmission triageSubmission) { var url = $"{_configuration.BaseUrl}api/provider/{providerId}/apprenticeships/{apprenticeshipId}/datalocks"; var data = JsonConvert.SerializeObject(triageSubmission); await PatchAsync(url, data); }
protected override async Task Handle(TriageApprenticeshipDataLocksCommand command, CancellationToken cancellationToken) { var validationResult = _validator.Validate(command); if (!validationResult.IsValid) { throw new ValidationException(validationResult.Errors); } var triageSubmission = new DataLockTriageSubmission { TriageStatus = command.TriageStatus, UserId = command.UserId }; try { await _commitmentsApi.PatchDataLocks(command.ProviderId, command.ApprenticeshipId, triageSubmission); } catch (Exception ex) { _logger.Error(ex, $"Error calling commitment API when updating multiple price data locks to status {command.TriageStatus} for apprenticeship {command.ApprenticeshipId}"); throw; } }
public async Task TriageDataLocks(long apprenticeshipId, DataLockTriageSubmission triageSubmission, Caller caller) { _logger.Trace($"Updating all data locks to triage status: {triageSubmission.TriageStatus}, for apprenticeship: {apprenticeshipId}", apprenticeshipId: apprenticeshipId, caller: caller); await _mediator.SendAsync(new TriageDataLocksCommand { ApprenticeshipId = apprenticeshipId, TriageStatus = (TriageStatus)triageSubmission.TriageStatus, UserId = triageSubmission.UserId }); _logger.Info($"Updated all data locks to triage status: {triageSubmission.TriageStatus}, for apprenticeship: {apprenticeshipId}", apprenticeshipId: apprenticeshipId, caller: caller); }
public async Task PatchDataLock() { var submission = new DataLockTriageSubmission { TriageStatus = TriageStatus.Change, UserId = "hello champ" }; var dataLockId = 007; var request = new TestRequest(new Uri(ExpectedApiBaseUrl + $"api/provider/{ProviderId}/apprenticeships/{ApprenticeshipId}/datalocks/{dataLockId}"), JsonConvert.SerializeObject(submission)); _fakeHandler.AddFakeResponse(request, new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(string.Empty) }); await _apiclient.PatchDataLock(ProviderId, ApprenticeshipId, dataLockId, submission); Assert.Pass(); }
protected override Task Handle(UpdateDataLockCommand command, CancellationToken cancellationToken) { _validator.ValidateAndThrow(command); try { var submission = new DataLockTriageSubmission { TriageStatus = command.TriageStatus, UserId = command.UserId }; return(_commitmentsApi.PatchDataLocks(command.ProviderId, command.ApprenticeshipId, submission)); } catch (Exception ex) { _logger.Error(ex, $"Error calling commitment API when updating data lock to status {command.TriageStatus} for apprenticeship {command.ApprenticeshipId}"); throw; } }
public async Task <IHttpActionResult> PatchDataLocks(long providerId, long apprenticeshipId, [FromBody] DataLockTriageSubmission triageSubmission) { await _apprenticeshipsOrchestrator.TriageDataLocks(apprenticeshipId, triageSubmission, new Caller(providerId, CallerType.Provider)); return(StatusCode(HttpStatusCode.NoContent)); }