private void RecordFileCreation(IToken token, FileInfo fileInfo)
        {
            var creationRecord = new AuditUpload
            {
                AuditId          = token.Audit.Id,
                EntityId         = 0,
                Title            = "Welcome Letter",
                Date             = DateTime.Now,
                Size             = $@"{(fileInfo.Length / 1024):N0} kb",
                AttachedBy       = 7,
                DocumentType     = token.Audit.AuditType == AuditTypeEnum.GL ? DocumentTypes.WelcomeLetterGl : DocumentTypes.WelcomeLetterWc,
                Description      = $@"Welcome Letter - {DateTime.Now:d}",
                Directory        = "~/WLArchive/",
                FilePath         = fileInfo.Name,
                OriginalFileName = fileInfo.Name,
            };

            var response = _auditUploadApplicationService.SaveAsync(creationRecord).Result;

            if (!response.IsSuccessful)
            {
                token.SetException(new InvalidOperationException(response.Message));
            }
        }
Esempio n. 2
0
        public async Task <SaveResponse <ICertificateOfInsurance> > SaveAsync(ICertificateOfInsurance certificateOfInsurance)
        {
            var saveResponse = new SaveResponse <ICertificateOfInsurance>();

            try
            {
                // Save file upload if a file was uploaded
                if (certificateOfInsurance.File != null)
                {
                    var fileUploadResponse = await _fileUploadApplicationService.SaveAsync(certificateOfInsurance.File);

                    certificateOfInsurance.File = fileUploadResponse.Content;
                }
                saveResponse = await _certificateOfInsuranceRepository.SaveAsync(certificateOfInsurance);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                saveResponse.AddError(ex);
                _logManager.LogError(ex, "Error saving certificateOfInsurance");
            }

            return(saveResponse);
        }