Пример #1
0
        public IActionResult Scan(string returnUrl, string sourceId, int sourceType)
        {
            var info = new ScanInfoViewModel()
            {
                ReturnUrl  = new Uri(returnUrl),
                SourceId   = sourceId,
                SourceType = sourceType
            };

            return(View(info));
        }
Пример #2
0
        public async Task <IActionResult> Scan(ScanInfoViewModel model)
        {
            if (string.IsNullOrEmpty(model.FileName))
            {
                model.FileName = $"ScannedDocument{DateTime.Now.ToString("ddMMyyHHmmss")}.pdf";
            }
            else if (!model.FileName.EndsWith(".pdf"))
            {
                model.FileName += ".pdf";
            }

            CdnUploadRequest fileModel = new CdnUploadRequest()
            {
                ContentType       = MediaTypeNames.Application.Pdf,
                FileContentBase64 = model.FileContent,
                FileName          = model.FileName,
                SourceId          = model.SourceId,
                SourceType        = model.SourceType,
                Title             = model.Title,
                UserUploaded      = userContext.UserId
            };

            var response = await cdnService.MongoCdn_UploadFile(fileModel);

            if (response != null && response.Succeded)
            {
                fileModel.FileId = response.FileId;
                SaveLogOperation("Scan", "Scan", $"Добавен нов файл {model.FileName}:{model.Title}", OperationTypes.Patch, fileModel.SourceId);

                return(Redirect(model.ReturnUrl.AbsoluteUri));
            }
            else
            {
                TempData[MessageConstant.ErrorMessage] = MessageConstant.Values.FileUploadFailed;

                return(Redirect(model.ReturnUrl.AbsoluteUri));
            }
        }
Пример #3
0
 public async Task <IViewComponentResult> InvokeAsync(ScanInfoViewModel info, string viewName = "")
 {
     return(await Task.FromResult(View(viewName, info)));
 }