Ejemplo n.º 1
0
        public async Task <List <CertificatePrintStatusUpdateMessage> > Update(Batch batch)
        {
            List <CertificatePrintStatusUpdateMessage> printStatusUpdateMessages = new List <CertificatePrintStatusUpdateMessage>();

            if (batch.Status == CertificateStatus.SentToPrinter)
            {
                _logger.LogInformation($"Batch log {batch.BatchNumber} will be updated as sent to printer");

                var updateRequest = new UpdateBatchLogSentToPrinterRequest()
                {
                    BatchCreated         = batch.BatchCreated,
                    NumberOfCertificates = batch.NumberOfCertificates,
                    NumberOfCoverLetters = batch.NumberOfCoverLetters,
                    CertificatesFileName = batch.CertificatesFileName,
                    FileUploadStartTime  = batch.FileUploadStartTime,
                    FileUploadEndTime    = batch.FileUploadEndTime,
                };

                var response = await _assessorServiceApiClient.UpdateBatchLogSentToPrinter(batch.BatchNumber, updateRequest);

                if (response.Errors.Count == 0)
                {
                    printStatusUpdateMessages.AddRange(BuildCertificatePrintStatusUpdateMessages(
                                                           batch.BatchNumber, batch.Certificates, batch.Status, DateTime.UtcNow));
                }
            }
            else if (batch.Status == CertificateStatus.Printed)
            {
                _logger.LogInformation($"Batch log {batch.BatchNumber} will be updated as printed");

                var updateRequest = new UpdateBatchLogPrintedRequest()
                {
                    BatchDate             = batch.BatchCreated,
                    PostalContactCount    = batch.NumberOfCoverLetters,
                    TotalCertificateCount = batch.NumberOfCertificates,
                    PrintedDate           = batch.PrintedDate,
                    DateOfResponse        = batch.DateOfResponse
                };

                var response = await _assessorServiceApiClient.UpdateBatchLogPrinted(batch.BatchNumber, updateRequest);

                if (response.Errors.Count == 0)
                {
                    printStatusUpdateMessages.AddRange(BuildCertificatePrintStatusUpdateMessages(
                                                           batch.BatchNumber, batch.Certificates, batch.Status, batch.PrintedDate.Value));
                }
            }

            if (printStatusUpdateMessages.Count > 0)
            {
                _logger.LogInformation($"Batch log {batch.BatchNumber} contained {batch.Certificates.Count} certificates, for which {printStatusUpdateMessages.Count} messages will be queued");
            }

            return(printStatusUpdateMessages);
        }
Ejemplo n.º 2
0
        public override void Arrange()
        {
            // Arrange
            base.Arrange();

            _batch = Builder <Batch> .CreateNew().Build();

            _batch.BatchNumber  = _batchNumber;
            _batch.Certificates = Builder <Certificate> .CreateListOfSize(13).All().Build() as List <Certificate>;

            _batch.Status = CertificateStatus.SentToPrinter;

            _request = new UpdateBatchLogSentToPrinterRequest()
            {
                BatchCreated         = _batch.BatchCreated,
                NumberOfCertificates = _batch.NumberOfCertificates,
                NumberOfCoverLetters = _batch.NumberOfCoverLetters,
                CertificatesFileName = _batch.CertificatesFileName,
                FileUploadStartTime  = _batch.FileUploadStartTime,
                FileUploadEndTime    = _batch.FileUploadEndTime,
            };

            _mockStorageQueue = new Mock <ICollector <string> >();
        }
Ejemplo n.º 3
0
 public async Task <ValidationResponse> UpdateBatchLogSentToPrinter(int batchNumber, UpdateBatchLogSentToPrinterRequest model)
 {
     using (var request = new HttpRequestMessage(HttpMethod.Put, $"/api/v1/batches/{batchNumber}/update-sent-to-printer"))
     {
         return(await PostPutRequestWithResponse <UpdateBatchLogSentToPrinterRequest, ValidationResponse>(request, model));
     }
 }
 public async Task <IActionResult> UpdateBatchLogSentToPrinter(int batchNumber, [FromBody] UpdateBatchLogSentToPrinterRequest request)
 {
     request.BatchNumber = batchNumber;
     return(Ok(await _mediator.Send(request)));
 }