Exemple #1
0
        public async Task <FilestorageDTO> PostFile(FilestorageDTO file)
        {
            var _file = ObjectMapper.Map <Filestorage>(file);

            _file.CreationTime = Clock.Now;
            var newFileId = await _fileRepository.InsertAndGetIdAsync(_file);

            var newFileHolder = await _fileRepository.GetAsync(newFileId);

            var newFile = ObjectMapper.Map <FilestorageDTO>(newFileHolder);

            return(newFile);
        }
Exemple #2
0
        public async Task <FilestorageDTO> PutFile(int Id, FilestorageDTO file)
        {
            var fileOld = await _fileRepository.GetAsync(Id);

            fileOld.Filename          = file.Name;
            fileOld.Contentstype      = file.ContentType;
            file.LastModificationTime = Clock.Now;

            var updatedHolder = await _fileRepository.UpdateAsync(fileOld);

            var updatedFile = ObjectMapper.Map <FilestorageDTO>(updatedHolder);

            return(updatedFile);
        }