public async Task <VacancySubmittedConfirmationViewModel> GetVacancySubmittedConfirmationViewModelAsync(VacancyRouteModel vrm, VacancyUser vacancyUser) { var vacancy = await _utility.GetAuthorisedVacancyAsync(vrm, RouteNames.Submitted_Index_Get); if (vacancy.Status != VacancyStatus.Submitted) { throw new InvalidStateException(string.Format(ErrorMessages.VacancyNotSubmittedSuccessfully, vacancy.Title)); } var isResubmit = false; if (vacancy.VacancyReference.HasValue) { var review = await _vacancyClient.GetCurrentReferredVacancyReviewAsync(vacancy.VacancyReference.Value); isResubmit = review != null; } var preferences = await _vacancyClient.GetUserNotificationPreferencesAsync(vacancyUser.UserId); var vm = new VacancySubmittedConfirmationViewModel { Title = vacancy.Title, VacancyReference = vacancy.VacancyReference?.ToString(), IsResubmit = isResubmit, HasNotificationsSet = preferences != null && preferences.NotificationTypes > NotificationTypes.None }; return(vm); }
public async Task <VacancySubmittedConfirmationViewModel> GetVacancySubmittedConfirmationViewModelAsync(VacancyRouteModel vrm) { var vacancy = await Utility.GetAuthorisedVacancyAsync(_client, _vacancyClient, vrm, RouteNames.Submitted_Index_Get); if (vacancy.Status != VacancyStatus.Submitted) { throw new InvalidStateException(string.Format(ErrorMessages.VacancyNotSubmittedSuccessfully, vacancy.Title)); } var isResubmit = false; if (vacancy.VacancyReference.HasValue) { var review = await _vacancyClient.GetCurrentReferredVacancyReviewAsync(vacancy.VacancyReference.Value); isResubmit = review != null; } var vm = new VacancySubmittedConfirmationViewModel { Title = vacancy.Title, VacancyReference = vacancy.VacancyReference?.ToString(), IsResubmit = isResubmit }; return(vm); }