Ejemplo n.º 1
0
        protected override async Task HandleCore(ResumeApprenticeshipCommand message)
        {
            var validationResult = _validator.Validate(message);

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

            var apprenticeshipSubmission = new ApprenticeshipSubmission
            {
                PaymentStatus     = PaymentStatus.Active,
                UserId            = message.UserId,
                LastUpdatedByInfo = new LastUpdateInfo {
                    EmailAddress = message.UserEmailAddress, Name = message.UserDisplayName
                }
            };
            await _commitmentApi.PatchEmployerApprenticeship(message.EmployerAccountId, message.ApprenticeshipId, apprenticeshipSubmission);
        }
Ejemplo n.º 2
0
        protected override async Task HandleCore(UpdateApprenticeshipStatusCommand command)
        {
            var validationResult = _validator.Validate(command);

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

            var apprenticeshipSubmission = new ApprenticeshipSubmission
            {
                PaymentStatus     = DeterminePaymentStatusForChange(command.ChangeType),
                DateOfChange      = command.DateOfChange,
                UserId            = command.UserId,
                MadeRedundant     = command.MadeRedundant,
                LastUpdatedByInfo = new LastUpdateInfo {
                    EmailAddress = command.UserEmailAddress, Name = command.UserDisplayName
                }
            };

            var apprenticeship = await _commitmentsApi.GetEmployerApprenticeship(command.EmployerAccountId, command.ApprenticeshipId);

            ValidateDateOfChange(apprenticeship, command, validationResult);

            await _commitmentsApi.PatchEmployerApprenticeship(command.EmployerAccountId, command.ApprenticeshipId, apprenticeshipSubmission);

            switch (command.ChangeType)
            {
            case ChangeStatusType.Stop: await _providerEmailNotificationService.SendProviderApprenticeshipStopNotification(apprenticeship, command.DateOfChange);

                break;

            case ChangeStatusType.Pause: await _providerEmailNotificationService.SendProviderApprenticeshipPauseNotification(apprenticeship, command.DateOfChange);

                break;

            case ChangeStatusType.Resume: await _providerEmailNotificationService.SendProviderApprenticeshipResumeNotification(apprenticeship, command.DateOfChange);

                break;
            }
        }
Ejemplo n.º 3
0
        protected override async Task HandleCore(UpdateApprenticeshipStatusCommand command)
        {
            var validationResult = _validator.Validate(command);

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

            var apprenticeshipSubmission = new ApprenticeshipSubmission
            {
                PaymentStatus     = DeterminePaymentStatusForChange(command.ChangeType),
                DateOfChange      = command.DateOfChange,
                UserId            = command.UserId,
                LastUpdatedByInfo = new LastUpdateInfo {
                    EmailAddress = command.UserEmailAddress, Name = command.UserDisplayName
                }
            };

            await ValidateDateOfChange(command, validationResult);

            await _commitmentsApi.PatchEmployerApprenticeship(command.EmployerAccountId, command.ApprenticeshipId, apprenticeshipSubmission);
        }
Ejemplo n.º 4
0
        public async Task <IHttpActionResult> PatchApprenticeship(long accountId, long apprenticeshipId, [FromBody] ApprenticeshipSubmission apprenticeshipSubmission)
        {
            await _employerOrchestrator.PatchApprenticeship(accountId, apprenticeshipId, apprenticeshipSubmission);

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 5
0
        public async Task PatchEmployerApprenticeship(long employerAccountId, long apprenticeshipId, ApprenticeshipSubmission apprenticeshipSubmission)
        {
            var url = $"{_configuration.BaseUrl}api/employer/{employerAccountId}/apprenticeships/{apprenticeshipId}";

            await _commitmentHelper.PatchApprenticeship(url, apprenticeshipSubmission);
        }
        public async Task PatchApprenticeship(string url, ApprenticeshipSubmission apprenticeshipSubmission)
        {
            var data = JsonConvert.SerializeObject(apprenticeshipSubmission);

            await PatchAsync(url, data);
        }