public async Task PatchApprenticeship(long accountId, long apprenticeshipId, Apprenticeship.ApprenticeshipSubmission apprenticeshipSubmission) { _logger.Trace($"Updating payment status to {apprenticeshipSubmission.PaymentStatus} for apprenticeship {apprenticeshipId} for employer account {accountId}", accountId: accountId, apprenticeshipId: apprenticeshipId); switch (apprenticeshipSubmission.PaymentStatus) { case PaymentStatus.Active: await IssueResumeCommand(accountId, apprenticeshipId, apprenticeshipSubmission); break; case PaymentStatus.Paused: await IssuePauseCommand(accountId, apprenticeshipId, apprenticeshipSubmission); break; case PaymentStatus.Withdrawn: await IssueStopCommand(accountId, apprenticeshipId, apprenticeshipSubmission); break; default: throw new ArgumentOutOfRangeException(nameof(apprenticeshipSubmission.PaymentStatus), "Not a valid value for change of status"); } _logger.Info($"Updated payment status to {apprenticeshipSubmission.PaymentStatus} for apprenticeship {apprenticeshipId} for employer account {accountId}", accountId: accountId, apprenticeshipId: apprenticeshipId); }
private async Task IssuePauseCommand(long accountId, long apprenticeshipId, Apprenticeship.ApprenticeshipSubmission apprenticeshipSubmission) { await _mediator.SendAsync(new PauseApprenticeshipCommand { Caller = new Caller(accountId, CallerType.Employer), AccountId = accountId, ApprenticeshipId = apprenticeshipId, DateOfChange = apprenticeshipSubmission.DateOfChange, UserId = apprenticeshipSubmission.UserId, UserName = apprenticeshipSubmission.LastUpdatedByInfo?.Name }); }