示例#1
0
        public async Task <long> CreateAsync(FileDto newFile)
        {
            FileDescriptor fileDesc = new FileDescriptor(newFile, _env);

            Folder.CreateIfNotExists(fileDesc.Path);
            File file = new File(fileDesc.Path, fileDesc.Name, fileDesc.Extension);
            await fileDesc.Override(file);

            return(await _fileRepo.CreateAsync(file));
        }
示例#2
0
        public async Task UpdateAsync(FileDto file)
        {
            try
            {
                File puttingFile = await _fileRepo.GetAsync(file.ID) ?? throw new EntityNotFoundException(file.ID);

                IO.File.Delete(puttingFile.ToString());
                FileDescriptor fileDesc = new FileDescriptor(file, _env);

                puttingFile.FileName  = fileDesc.Name;
                puttingFile.Path      = fileDesc.Path;
                puttingFile.Extension = fileDesc.Extension;

                await fileDesc.Override(puttingFile);

                await _fileRepo.ModifyAsync(puttingFile, file.ID);
            }
            catch (Exception)
            {
                throw;
            }
        }