Пример #1
0
        public async Task ThenCallsOrchestratorWithTheCorrectParameters()
        {
            var request = new TransferApprovalRequest
            {
                TransferReceiverId     = 112,
                TransferApprovalStatus = TransferApprovalStatus.Approved
            };

            await _sut.PatchTransferApprovalStatus(111, 3, 12, request);

            _mockEmployerOrchestrator.Verify(x => x.SetTransferApprovalStatus(111, 3, 12, request));
        }
Пример #2
0
        protected override async Task HandleCore(TransferApprovalCommand message)
        {
            var commitment =
                await _commitmentsService.GetTransferSenderCommitment(message.TransferSenderId, message.CommitmentId);

            if (commitment.TransferSender.Id != message.TransferSenderId)
            {
                throw new InvalidRequestException(new Dictionary <string, string>
                {
                    { "Commitment", "This commitment does not belong to this Transfer Sender Account" }
                });
            }

            if (commitment.TransferSender.TransferApprovalStatus !=
                Commitments.Api.Types.TransferApprovalStatus.Pending)
            {
                var status = commitment.TransferSender.TransferApprovalStatus ==
                             Commitments.Api.Types.TransferApprovalStatus.Approved
                    ? "approved"
                    : "rejected";

                throw new InvalidRequestException(new Dictionary <string, string>
                {
                    { "Commitment", $"This transfer request has already been {status}" }
                });
            }

            var request = new TransferApprovalRequest
            {
                TransferApprovalStatus = message.TransferStatus,
                TransferReceiverId     = commitment.EmployerAccountId,
                UserId    = message.UserId,
                UserEmail = message.UserEmail,
                UserName  = message.UserName
            };

            await _commitmentsService.PatchTransferApprovalStatus(message.TransferSenderId, message.CommitmentId, message.TransferRequestId, request);

            await SendNotifications(commitment, message.TransferStatus);
        }
        public Task PatchTransferApprovalStatus(long transferSenderId, long commitmentId, long transferRequestId, TransferApprovalRequest request)
        {
            var url  = $"{_configuration.BaseUrl}api/employer/{transferSenderId}/transfers/{transferRequestId}/approval/{commitmentId}";
            var data = JsonConvert.SerializeObject(request);

            return(PatchAsync(url, data));
        }
        public async Task <IHttpActionResult> PatchTransferApprovalStatus(long transferSenderId, long commitmentId, long transferRequestId, TransferApprovalRequest request)
        {
            await _employerOrchestrator.SetTransferApprovalStatus(transferSenderId, commitmentId, transferRequestId, request);

            return(Ok());
        }