Пример #1
0
        /// <summary>
        /// Add files from an existing list of FileBoxItems to the comment.
        /// </summary>
        /// <param name="files">The FileBoxItems to add to the comment.</param>
        public void AddFiles(IEnumerable <FileBoxItem> files)
        {
            var filebox = GetOrCreateFileBox();

            foreach (var fileBoxItem in files)
            {
                FileBoxItem.CreateNew(filebox.Id, fileBoxItem.File);
            }
        }
Пример #2
0
        public static FileBoxItem CreateNew(int fileBoxId, IFile file, string comment = null)
        {
            var fileBoxItem = new FileBoxItem()
            {
                FileBoxId     = fileBoxId,
                FileId        = file.Id,
                Name          = file.Name,
                FileExtension = Path.GetExtension(file.Name),
                Comment       = comment
            };

            BaseUserContext.Instance.Repository.Add <Entities.FileBoxItem, FileBoxItem>(fileBoxItem);
            return(fileBoxItem);
        }
Пример #3
0
        public FileBoxItem AddFile(HttpPostedFileBase file, string businessKey, int?groupdId = null, string comment = null, string langId = null, bool requireLogin = true)
        {
            if (file == null || file.ContentLength == 0)
            {
                return(null);
            }

            var newFile = File.CreateNewFile <File>(System.IO.Path.GetFileName(file.FileName), businessKey, groupdId, requireLogin, langId);

            using (var fileStream = newFile.OpenWrite())
            {
                file.InputStream.CopyTo(fileStream);
                fileStream.Flush();
            }

            return(FileBoxItem.CreateNew(Id, newFile, comment));
        }
Пример #4
0
        private void AddFiles(IEnumerable <int> fileIds)
        {
            if (fileIds == null)
            {
                return;
            }

            var filebox = GetOrCreateFileBox();

            foreach (var fileId in fileIds)
            {
                var file = File.Get(fileId);

                if (file == null)
                {
                    continue;
                }

                FileBoxItem.CreateNew(filebox.Id, file);
            }
        }
Пример #5
0
 public FileBoxItem AddFile(IFile file, string comment = null)
 {
     return(FileBoxItem.CreateNew(Id, file, comment));
 }
Пример #6
0
 public IEnumerable <FileBoxItem> GetFiles()
 {
     return(FileBoxItem.GetByFileBoxId(Id));
 }
Пример #7
0
        public void AddFile(File file)
        {
            var filebox = GetOrCreateFileBox();

            FileBoxItem.CreateNew(filebox.Id, file);
        }