Ejemplo n.º 1
0
        public async Task <Unit> Handle(MoveFileToFolderCommand request, CancellationToken cancellationToken)
        {
            await _service.MoveFileToFolder(new MoveFileRequestModel(request.NewParentFolderId, request.FullFilePath)
            {
                AccessToken = await _tokenDataService.GetUserAccessToken(Guid.Parse(_userAccessor.GetUser().FindFirst(ClaimTypes.NameIdentifier).Value), request.ExternalProvider)
            });

            return(Unit.Value);
        }
Ejemplo n.º 2
0
        public async Task <Unit> Handle(MoveFolderToDirectoryCommand request, CancellationToken cancellationToken)
        {
            await _service.MoveFolderIntoAnotherDirectory(
                new MoveFolderContentFolderRequestModel(request.OldPath, request.NewPath, request.FolderName, request.ProjectNumber)
            {
                AccessToken = await _tokenDataService.GetUserAccessToken(
                    Guid.Parse(_userAccessor.GetUser().FindFirst(ClaimTypes.NameIdentifier).Value),
                    request.ExternalProvider)
            });

            return(Unit.Value);
        }
Ejemplo n.º 3
0
        public async Task <Unit> Handle(DeleteFileCommand request, CancellationToken cancellationToken)
        {
            await _service.DeleteElement(new CloudStorageApiRequestModel()
            {
                Id          = request.Id,
                Path        = request.FilePath,
                ElementName = request.FileName,
                AccessToken = await _tokenDataService.GetUserAccessToken(Guid.Parse(_userAccessor.GetUser().FindFirst(ClaimTypes.NameIdentifier).Value), request.ExternalProvider)
            });

            return(Unit.Value);
        }
Ejemplo n.º 4
0
        public async Task <Unit> Handle(RefreshCurrentUserTokenCommand request, CancellationToken cancellationToken)
        {
            var userId      = Guid.Parse(_userAccessor.GetUser().FindFirst(ClaimTypes.NameIdentifier).Value);
            var accessToken = await _tokenDataService.GetUserAccessToken(userId, request.ExternalProvider);

            var userRefreshToken = await _tokenDataService.GetUserRefreshToken(userId, request.ExternalProvider);

            await _authorizationService.VerifyUser(accessToken, userRefreshToken
                                                   , userId, request.ExternalProvider, _config.CurrentValue.ClientId,
                                                   _config.CurrentValue.ReturnUrl, _config.CurrentValue.ClientSecret);

            return(Unit.Value);
        }
Ejemplo n.º 5
0
        public async Task <HttpResponseMessage> Handle(UploadFileCommand request, CancellationToken cancellationToken)
        {
            HttpResponseMessage response = await _service.UploadFile(new CloudStorageApiRequestModel()
            {
                Path        = request.Filepath,
                File        = request.FormFile,
                AccessToken = await _tokenDataService.GetUserAccessToken(
                    Guid.Parse(_userAccessor.GetUser().FindFirst(ClaimTypes.NameIdentifier).Value),
                    request.ExternalProvider)
            });

            return(response);
        }
Ejemplo n.º 6
0
        public async Task <List <CloudMetaData> > Handle(GetChildrenQuery request, CancellationToken cancellationToken)
        {
            var user     = _userAccessor.GetUser();
            var userId   = Guid.Parse(user.FindFirst(ClaimTypes.NameIdentifier).Value);
            var children = await _storageBaseService.GetChildren(new CloudStorageApiRequestModel()
            {
                Path        = request.FilePath,
                AccessToken = await _userTokenDataService.GetUserAccessToken(
                    userId,
                    request.ExternalProvider)
            });

            return(children);
        }