public static ApprenticeshipProgrammeViewModel ToViewModel(this IApprenticeshipProgramme programme) { string educationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.Level); return(new ApprenticeshipProgrammeViewModel { Id = programme.Id, Name = $"{programme.Title}, {educationLevelName}" }); }
public async Task <OrchestratorResponse <Guid> > PostTitleEditModelAsync(TitleEditModel m, VacancyUser user) { TrainingProvider provider = null; IApprenticeshipProgramme programme = null; if (!m.VacancyId.HasValue) // Create if it's a new vacancy { var newVacancy = new Vacancy { Title = m.Title }; return(await ValidateAndExecute( newVacancy, v => _vacancyClient.Validate(v, ValidationRules), async v => { if (m.ReferredFromSavedFavourites) { provider = await GetProvider(m.ReferredUkprn); programme = await GetProgramme(m.ReferredProgrammeId); } return await _client.CreateVacancyAsync(m.Title, m.EmployerAccountId, user, provider, programme?.Id); })); } var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(new VacancyRouteModel { EmployerAccountId = m.EmployerAccountId, VacancyId = m.VacancyId.Value }, RouteNames.Title_Post); SetVacancyWithEmployerReviewFieldIndicators( vacancy.Title, FieldIdResolver.ToFieldId(v => v.Title), vacancy, (v) => { return(v.Title = m.Title); }); return(await ValidateAndExecute( vacancy, v => _vacancyClient.Validate(v, ValidationRules), async v => { await _vacancyClient.UpdateDraftVacancyAsync(vacancy, user); return v.Id; } )); }
private void ManageTempData(TrainingProviderSummary provider, IApprenticeshipProgramme programme) { if (provider != null) { TempData[TempDataKeys.ReferredUkprn] = provider.Ukprn; } else { TempData.Remove(TempDataKeys.ReferredUkprn); } if (programme != null) { TempData[TempDataKeys.ReferredProgrammeId] = programme.Id; } else { TempData.Remove(TempDataKeys.ReferredProgrammeId); } }