public async Task <DownloadFileDto> GetFileById(int id, int userId, int clientId) { var fileStorageRepository = DataContextManager.CreateRepository <IFileStorageRepository>(); var fileStorage = await fileStorageRepository.GetById(id, userId, clientId); if (fileStorage == null || fileStorage != null && fileStorage.IsDirectory) { throw new NotFoundException("File storage", id); } var file = fileStorage.Files.FirstOrDefault(x => x.IsActive); if (file == null) { throw new NotFoundDependencyObjectException("File"); } var buffer = await _azureBlobClient.DownloadFile(_blobSettings.ContainerName, file.AzureBlobStorage.BlobName.ToString()); return(new DownloadFileDto { Name = fileStorage.Name, Extension = file.Extension, Buffer = buffer }); }