public async Task <IActionResult> Post([FromForm] BatchSubmitModel model) { var result = await _batchSubmissionService.ProcessBatch(model); return(AcceptedAtAction( nameof(GetBatchStatus), new { id = result }, null)); }
public async Task <Guid> ProcessBatch(BatchSubmitModel model) { var id = Guid.NewGuid(); var batch = new Batch { Id = id, BatchUri = $"HealthcareClaimsV1/{id}.json", CreationDate = DateTime.UtcNow }; _batchesContext.Batches.Add(batch); using (var stream = model.BatchJsonFile.OpenReadStream()) { await _objectsStorageService.UploadObjectAsync( "healthcare-claims-app-v1", batch.BatchUri, stream); } await _batchesContext.SaveChangesAsync(); var batchJobData = new BatchJobData { BatchId = batch.Id }; var submissionJobId = _backgroundJobClient .Enqueue <GenerateBatchSubmissionFeedbackDocumentJob>( job => job.Execute(batchJobData, null, JobCancellationToken.Null)); _backgroundJobClient .ContinueJobWith <VetBatchJob>( submissionJobId, job => job.Execute(batchJobData, null, JobCancellationToken.Null)); _logger.LogInformation("Batch submission initiated: {Id}", batch.Id); return(batch.Id); }