Esempio n. 1
0
        public async Task <bool> FileExistsAsync(File file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            if (string.IsNullOrWhiteSpace(file.Path))
            {
                return(SystemFile.Exists(await _helperPath.GetAbsoluteFilePathAsync(file)));
            }

            var path = Path.Combine(_helperPath.GetContentPath(), file.Path.Replace("/", "\\"));

            return(SystemFile.Exists(path));
        }
Esempio n. 2
0
        public async Task <string> GetRelativeFilePathAsync(File file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            DatabaseFile model = null;

            if (file.Guid.HasValue)
            {
                model = await _repositoryFile.FindFirstAsync(new FilesByGuid(file.Guid.Value));
            }

            model = model ?? await _repositoryFile.FindFirstAsync(new FilesById(file.Id)) ??
                    throw ExceptionHelper.NotFound <DatabaseFile>(file.Id);

            return(GetRelativeFilePath(model));
        }
Esempio n. 3
0
 public async Task <string> GetAbsoluteFilePathAsync(File file)
 => Path.Combine(GetContentPath(), await GetRelativeFilePathAsync(file));