예제 #1
0
        public override IAuditUpload ToModel()
        {
            var model = new AuditUpload
            {
                Id               = AuditUploadsId,
                Title            = Title,
                Date             = Date,
                Data             = FileData,
                Size             = Size,
                AttachedBy       = AttachedBy,
                DocumentType     = DocumentTypes.NotSet,
                Description      = Description,
                AuditId          = AuditId,
                EntityId         = EntityId,
                FilePath         = FilePath,
                Directory        = Directory,
                OriginalFileName = OriginalFileName
            };

            return(model);
        }
        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));
            }
        }