Beispiel #1
0
        protected override async Task HandleCore(DeleteApprenticeshipCommand message)
        {
            var validationResult = _validator.Validate(message);

            if (!validationResult.IsValid())
            {
                throw new InvalidRequestException(validationResult.ValidationDictionary);
            }

            var apprenticeship = await _commitmentsApi.GetEmployerApprenticeship(message.AccountId, message.ApprenticeshipId);

            var commitment = await
                             _commitmentsApi.GetEmployerCommitment(message.AccountId, apprenticeship.CommitmentId);

            await _commitmentsApi.DeleteEmployerApprenticeship(message.AccountId, message.ApprenticeshipId,
                                                               new DeleteRequest { UserId = message.UserId, LastUpdatedByInfo = new LastUpdateInfo {
                                                                                       EmailAddress = message.UserEmailAddress, Name = message.UserDisplayName
                                                                                   } });

            if (commitment.TransferSender?.TransferApprovalStatus ==
                Commitments.Api.Types.TransferApprovalStatus.Rejected)
            {
                await _providerEmailNotificationService.SendProviderTransferRejectedCommitmentEditNotification(
                    commitment);
            }
        }
Beispiel #2
0
        public async Task <GetCommitmentQueryResponse> Handle(GetCommitmentQueryRequest message)
        {
            var commitment = await _commitmentsApi.GetEmployerCommitment(message.AccountId, message.CommitmentId);

            return(new GetCommitmentQueryResponse
            {
                Commitment = commitment
            });
        }
        public async Task <CreateCommitmentCommandResponse> Handle(CreateCommitmentCommand request)
        {
            // TODO: This needs to return just the Id
            var commitmentRequest = new CommitmentRequest {
                Commitment = request.Commitment, UserId = request.UserId, Message = request.Message
            };
            var commitmentId = (await _commitmentApi.CreateEmployerCommitment(request.Commitment.EmployerAccountId, commitmentRequest)).Id;
            var commitment   = await _commitmentApi.GetEmployerCommitment(request.Commitment.EmployerAccountId, commitmentId);

            if (request.Commitment.CommitmentStatus == CommitmentStatus.Active)
            {
                await SendNotification(commitment);
            }

            return(new CreateCommitmentCommandResponse {
                CommitmentId = commitment.Id
            });
        }
        protected override async Task HandleCore(SubmitCommitmentCommand message)
        {
            var validationResult = _validator.Validate(message);

            if (!validationResult.IsValid())
            {
                throw new InvalidRequestException(validationResult.ValidationDictionary);
            }

            var commitment = await _commitmentApi.GetEmployerCommitment(message.EmployerAccountId, message.CommitmentId);

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

            var submission = new CommitmentSubmission
            {
                Action            = message.LastAction,
                LastUpdatedByInfo = new LastUpdateInfo {
                    Name = message.UserDisplayName, EmailAddress = message.UserEmailAddress
                },
                UserId  = message.UserId,
                Message = message.Message
            };

            if (message.LastAction != LastAction.Approve)
            {
                await _commitmentApi.PatchEmployerCommitment(message.EmployerAccountId, message.CommitmentId, submission);
            }
            else
            {
                await _commitmentApi.ApproveCohort(message.EmployerAccountId, message.CommitmentId, submission);
            }

            if (_configuration.CommitmentNotification.SendEmail &&
                message.LastAction != LastAction.None)
            {
                await SendNotification(commitment, message);
            }
            _logger.Info("Submit commitment");
        }
        public async Task <GetCommitmentQueryResponse> Handle(GetCommitmentQueryRequest message)
        {
            CommitmentView commitment = null;

            switch (message.CallerType)
            {
            case CallerType.Employer:
                commitment = await _commitmentsApi.GetEmployerCommitment(message.AccountId, message.CommitmentId);

                break;

            case CallerType.TransferSender:
                commitment = await _commitmentsApi.GetTransferSenderCommitment(message.AccountId, message.CommitmentId);

                break;
            }

            return(new GetCommitmentQueryResponse
            {
                Commitment = commitment
            });
        }