public async Task <CompleteUploadSessionResponse> Handle(CompleteUploadSessionCommand request, CancellationToken cancellationToken)
        {
            var session = await _sessions.FindNotCompletedSessionAsync(request.UploadId, cancellationToken);

            if (session == null)
            {
                return(null);
            }

            var uploadedBlockList = (await _blobStorage.GetBlockListAsync(session.Id, cancellationToken)).ToList();

            var corruptedParts = FindCorruptedParts(session, uploadedBlockList);

            if (corruptedParts.Count != 0)
            {
                return(new CompleteUploadSessionResponse(corruptedParts));
            }

            await FinishUploadSessionAsync(session, uploadedBlockList, cancellationToken);

            _eventBus.Publish(
                new FileUploadedEvent
            {
                UploadId    = session.Id,
                SizeInBytes = session.SizeInBytes,
                FileName    = session.FileName,
                Extension   = Enum.Parse <FileExtension>(session.Extension, true)
            });

            return(new CompleteUploadSessionResponse());
        }
        public async Task <bool> Handle(UploadPartCommand request, CancellationToken cancellationToken)
        {
            var session = _sessions.FindNotCompletedSessionAsync(request.UploadId, cancellationToken);

            if (session == null)
            {
                return(false);
            }

            return(await _blobStorage.UploadBlockBlob(request.Part, request.UploadId, request.PartId, cancellationToken));
        }