public async Task <WorkspaceSummaryResponseType> Handle(GetPexaWorkspaceSummaryQuery request, CancellationToken cancellationToken) { if (request is null) { throw new ArgumentNullException(nameof(request)); } await _validator.ValidateAndThrowAsync(request); var workspaceSummary = await _pexaService.Handle <WorkspaceSummaryResponseType>( new RetrieveWorkspaceSummaryRequestQuery(request.RetrieveWorkspaceSummaryParameters, request.AccessToken), request.AuthenticatedUser, cancellationToken); return(workspaceSummary); }
public async Task <WorkgroupListRetrievalResponseType> Handle(GetPexaWorkgroupsQuery request, CancellationToken cancellationToken) { if (request is null) { throw new ArgumentNullException(nameof(request)); } await _validator.ValidateAndThrowAsync(request); var subscriberSearchResponse = await _pexaService.Handle <WorkgroupListRetrievalResponseType>( new RetrieveWorkgroupsQuery(request.AccessToken), request.AuthenticatedUser, cancellationToken); return(subscriberSearchResponse); }
public async Task <SubscriberSearchResponseType> Handle(SearchSubscriberQuery request, CancellationToken cancellationToken) { if (request is null) { throw new ArgumentNullException(nameof(request)); } await _validator.ValidateAndThrowAsync(request); var subscriberSearchResponse = await _pexaService.Handle <SubscriberSearchResponseType>( new SearchSubscriberRequestQuery(request.SubscriberInformation, request.AccessToken), request.AuthenticatedUser, cancellationToken); return(subscriberSearchResponse); }
public async Task <LandTitleReferenceVerificationResponseType> Handle(ValidateLandTitleReferenceQuery request, CancellationToken cancellationToken) { if (request is null) { throw new ArgumentNullException(nameof(request)); } await _validator.ValidateAndThrowAsync(request); var landTitleReferenceVerificationResponse = await _pexaService.Handle <LandTitleReferenceVerificationResponseType>( new CheckLandTitleStatusQuery(request.LandTitleReferenceAndJurisdiction, request.AccessToken), request.AuthenticatedUser, cancellationToken); return(landTitleReferenceVerificationResponse); }
public async Task <RetrieveSettlementAvailabilityResponseType> Handle(GetAvailableSettlementTimesQuery request, CancellationToken cancellationToken) { if (request is null) { throw new ArgumentNullException(nameof(request)); } await _validator.ValidateAndThrowAsync(request); var settlementAvailability = await _pexaService.Handle <RetrieveSettlementAvailabilityResponseType>( new RetrieveSettlementAvailabilityQuery(request.RetrieveSettlementAvailabilityParams, request.AccessToken), request.AuthenticatedUser, cancellationToken); return(settlementAvailability); }
public async Task <CreateWorkspaceInvitationResponseType[]> Handle(CreatePexaWorkspaceInvitationCommand command, CancellationToken cancellationToken) { if (command is null) { throw new ArgumentNullException(nameof(command)); } await _validator.ValidateAndThrowAsync(command); var response = new List <CreateWorkspaceInvitationResponseType>(); foreach (var invitationRequest in command.PexaWorkspaceInvitationRequests) { var workspaceInvitationResponse = await _pexaService.Handle <CreateWorkspaceInvitationResponseType>( new WorkspaceInvitationRequestCommand(invitationRequest, command.AccessToken), command.AuthenticatedUser, cancellationToken); response.Add(workspaceInvitationResponse); } return(response.ToArray()); }
public async Task <CreatePexaWorkspaceResponse> Handle(CreatePexaWorkspaceCommand command, CancellationToken cancellationToken) { if (command is null) { throw new ArgumentNullException(nameof(command)); } await _validator.ValidateAndThrowAsync(command); // Check that the user has valid Actionstep credentials for the given Actionstep Matter in Subscriber Reference if (!_wCADbContext.ActionstepCredentials.UserHasValidCredentialsForOrg(command.AuthenticatedUser, command.OrgKey)) { throw new UnauthorizedAccessException($"User {command.AuthenticatedUser.Id} does not have valid Actionstep credentials for org {command.OrgKey} which is specified in the PEXA Subscriber Reference field."); } // Load Actionstep matter aggregate. SubscriberReference should already be in correct Aggregate Id format var actionstepMatter = _actionstepMatterRepository.GetById(command.PexaWorkspaceCreationRequest.SubscriberReference); if (actionstepMatter.Id == null) { actionstepMatter = new ActionstepMatter(_clock.GetCurrentInstant(), command.OrgKey, command.MatterId, command.AuthenticatedUser.Id); } PexaWorkspaceCreationRequested pexaWorkspaceCreationRequested = null; try { // Mark request for PEXA workspace creation pexaWorkspaceCreationRequested = actionstepMatter.RequestPexaWorkspaceCreation(_clock.GetCurrentInstant(), command.AuthenticatedUser.Id); _actionstepMatterRepository.Save(actionstepMatter); // Call PEXA and attempt to create workspace var workspaceCreationResponse = await _pexaService.Handle <WorkspaceCreationResponse>( new WorkspaceCreationRequestCommand(command.PexaWorkspaceCreationRequest, command.AccessToken), command.AuthenticatedUser, cancellationToken); var urlSafeId = Uri.EscapeDataString(workspaceCreationResponse.WorkspaceId); if (string.IsNullOrEmpty(urlSafeId)) { throw new PexaUnexpectedErrorResponseException("PEXA Request came back successful but there was no PEXA Workspace ID."); } // If sucessful, save immediately actionstepMatter.MarkPexaWorkspaceCreated(_clock.GetCurrentInstant(), workspaceCreationResponse.WorkspaceId, pexaWorkspaceCreationRequested); _actionstepMatterRepository.Save(actionstepMatter); var workspaceUri = _pexaService.GetWorkspaceUri(workspaceCreationResponse.WorkspaceId, command.PexaWorkspaceCreationRequest.Role); var invitationUri = _pexaService.GetInvitationUri(workspaceCreationResponse.WorkspaceId, command.PexaWorkspaceCreationRequest.Role); return(new CreatePexaWorkspaceResponse(workspaceUri, workspaceCreationResponse.WorkspaceId, invitationUri)); } catch (PexaWorkspaceAlreadyExistsException ex) { var workspaceUri = _pexaService.GetWorkspaceUri(ex.WorkspaceId, command.PexaWorkspaceCreationRequest.Role); var invitationUri = _pexaService.GetInvitationUri(ex.WorkspaceId, command.PexaWorkspaceCreationRequest.Role); return(new CreatePexaWorkspaceResponse(workspaceUri, ex.WorkspaceId, invitationUri, true)); } catch (Exception ex) { actionstepMatter.MarkPexaWorkspaceCreationFailed(_clock.GetCurrentInstant(), ex.Message, pexaWorkspaceCreationRequested); _actionstepMatterRepository.Save(actionstepMatter); throw; } }