Example #1
0
        private async Task <Tuple <Stream, FileDto> > GetConcreteVersionOfFile(Node file, int versionOfFile)
        {
            var getVersionOfFile =
                await _unitOfWork.FileVersionRepository.GetFileVersionOfVersionNumber(file, versionOfFile);

            if (getVersionOfFile == null)
            {
                State.TypeOfError  = TypeOfServiceError.NotFound;
                State.ErrorMessage = "Requeset version not found!";
                return(Tuple.Create <Stream, FileDto>(null, null));
            }
            var streamOfFileFromBlob = await _blobService.DownloadFileAsync(getVersionOfFile.PathToFile);

            if (streamOfFileFromBlob == null)
            {
                State.TypeOfError  = TypeOfServiceError.ConnectionError;
                State.ErrorMessage = "Error with getting file from Azure blob storage!";
                return(Tuple.Create <Stream, FileDto>(null, null));
            }

            // Set start position of the stream
            streamOfFileFromBlob.Position = 0;
            return(Tuple.Create(streamOfFileFromBlob, Mapper.Map <Node, FileDto>(file)));
        }