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); }
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; } }
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); }
public async Task <IHttpActionResult> PatchApprenticeship(long accountId, long apprenticeshipId, [FromBody] ApprenticeshipSubmission apprenticeshipSubmission) { await _employerOrchestrator.PatchApprenticeship(accountId, apprenticeshipId, apprenticeshipSubmission); return(StatusCode(HttpStatusCode.NoContent)); }
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); }