예제 #1
0
        private Response ExecuteCreateBarcodeEndPoint(dynamic parameters)
        {
            var fileName = "barcode.png";

            if (string.IsNullOrWhiteSpace(parameters.text))
            {
                return(HttpStatusCode.BadRequest);
            }
            var inputData = new CreateBarCodeRequest
            {
                Text            = parameters.text,
                CheckSumEnabled = parameters.checkSumEnabled
            };

            var result   = CreateBarCodeUseCase.Execute(inputData);
            var stream   = new MemoryStream(result.BarCode);
            var response = new StreamResponse(() => stream, MimeTypes.GetMimeType(fileName));

            response.AsAttachment(fileName);
            return(response);
        }
        public byte[] Execute(RenderReportRequest request)
        {
            var path       = GetFile(request.FileName);
            var fileLoader = _fileSystemProvider.LoadFile(path);

            if (fileLoader.Length == 0)
            {
                return(new byte[0]);
            }
            var fieldsOperator = _pdfFieldsOperations.Execute(fileLoader, request.ListOfFields);
            var barCodeCreator = _createBarCodeUseCase.Execute(request.QrCodeData);

            var config = CreateMapperConfiguration();
            var attachBarCodeRequest = Map(request.Barcode, fieldsOperator, barCodeCreator, config);
            var barCodeAttacher      = _attachQrCodeUseCase.Execute(attachBarCodeRequest);

            if (!string.IsNullOrWhiteSpace(request.Password))
            {
                var passwordProtecter = _passwordProtectOperation.PasswordProtect(barCodeAttacher.OutputFileBytes, request.Password);
                return(passwordProtecter);
            }

            return(barCodeAttacher.OutputFileBytes);
        }