コード例 #1
0
        protected async Task <string> UploadDocumentsAsync(UpdateDocumentDto document)
        {
            List <string> files      = new List <string>();
            string        folderPath = await GetFolderPathAsync(document.Code);

            string uploadFolderPath = await SettingProvider.GetOrNullAsync(DocumentManagementSettings.UploadFilePath);

            if (document.Files != null && document.Files.Any())
            {
                foreach (IFormFile file in document.Files)
                {
                    string filePath = $"{folderPath}/{file.FileName}";
                    document.FolderName = folderPath.Replace(uploadFolderPath, string.Empty);
                    document.LinkFile   = $"/downloadfile/viewfile?sourcedoc={folderPath.Replace(folderPath, string.Empty)}/{file.FileName}";
                    files.Add(file.FileName);
                    await SaveAsAsync(filePath, file);
                }
            }

            if (document.AppendixFiles != null && document.AppendixFiles.Any())
            {
                int index = 0;
                foreach (IFormFile file in document.AppendixFiles)
                {
                    string filePath = $"{folderPath}/{file.FileName}";
                    await SaveAsAsync(filePath, file);

                    document.Appendixes[index].FolderName = folderPath.Replace(uploadFolderPath, string.Empty);
                    document.Appendixes[index].LinkFile   = $"/downloadfile/viewfile?sourcedoc={folderPath.Replace(folderPath, string.Empty)}/{file.FileName}";
                    index++;
                }
            }
            return(string.Join(";", files));
        }
コード例 #2
0
        public async Task <DocumentDto> UpdateAndReleaseAsync(long id, [FromForm] UpdateDocumentDto input)
        {
            var result = await _documentAppService.UpdateAsync(id, input);

            await _documentEmailSenderService.SendMailReleaseDocumentAsync(result);

            return(result);
        }
コード例 #3
0
        public async Task UpdateDocument(string accountReference, int documentId)
        {
            var url = $"{_portalSettings.GatewayEndpoint}api/Documents/UpdateDocument";

            var date = DateTime.UtcNow.ToString("s") + "Z";

            UpdateDocumentDto dto = new UpdateDocumentDto()
            {
                AccountId  = accountReference,
                DocumentId = documentId,
                Read       = date
            };

            await _restClient.PostNoResponseAsync(url, dto);
        }
コード例 #4
0
        public void UpdateDocument(UpdateDocumentDto input)
        {
            var getGetDoc = (from document in _documentRepo.GetAll()
                             where document.entityCode == "1" &&
                             document.psCode == input.psCode &&
                             document.documentType == input.documentType
                             select document).FirstOrDefault();

            var update = getGetDoc.MapTo <TR_Document>();

            if (input.documentBinary == "updated")
            {
                var fileToDelete = getGetDoc.documentBinary;

                if (fileToDelete != null && fileToDelete != "")
                {
                    DeleteFile(fileToDelete);
                }

                var imageUrl = UploadFile(input.documentBinaryNew);
                GetURLWithoutHost(imageUrl, out imageUrl);
                update.documentBinary = imageUrl;
            }
            else if (input.documentBinary == "existing")
            {
                update.documentBinary = getGetDoc.documentBinary;
            }

            try
            {
                _documentRepo.UpdateAsync(update);
                CurrentUnitOfWork.SaveChanges();
            }
            // Handle data errors.
            catch (DataException exDb)
            {
                throw new UserFriendlyException("Database Error : {0}", exDb.Message);
            }
            // Handle all other exceptions.
            catch (Exception ex)
            {
                throw new UserFriendlyException("Error : {0}", ex.Message);
            }
        }
コード例 #5
0
        public async Task <DocumentDto> UpdateAsync(long id, [FromForm] UpdateDocumentDto input)
        {
            var result = await _documentAppService.UpdateAsync(id, input);

            return(result);
        }