/// <summary>
        /// Gets vacancy for display without applications.
        /// </summary>
        /// <param name="vacancy"></param>
        /// <returns></returns>
        public async Task <DisplayVacancyViewModel> GetFullVacancyDisplayViewModelAsync(Vacancy vacancy)
        {
            switch (vacancy.Status)
            {
            case VacancyStatus.Approved:
                var approvedViewModel = new ApprovedVacancyViewModel();
                await _vacancyDisplayMapper.MapFromVacancyAsync(approvedViewModel, vacancy);

                approvedViewModel.ApprovedDate = vacancy.ApprovedDate.Value.AsGdsDate();
                return(approvedViewModel);

            case VacancyStatus.Live:
                var liveViewModel = new LiveVacancyViewModel();
                await _vacancyDisplayMapper.MapFromVacancyAsync(liveViewModel, vacancy);

                return(liveViewModel);

            case VacancyStatus.Closed:
                var closedViewModel = new ClosedVacancyViewModel();
                await _vacancyDisplayMapper.MapFromVacancyAsync(closedViewModel, vacancy);

                return(closedViewModel);

            case VacancyStatus.Submitted:
                var submittedViewModel = new SubmittedVacancyViewModel();
                await _vacancyDisplayMapper.MapFromVacancyAsync(submittedViewModel, vacancy);

                submittedViewModel.SubmittedDate = vacancy.SubmittedDate.Value.AsGdsDate();
                return(submittedViewModel);

            default:
                throw new InvalidStateException(string.Format(ErrorMessages.VacancyCannotBeViewed, vacancy.Title));
            }
        }
        private ViewVacancy GetDisplayViewModelForClosedVacancy(Vacancy vacancy)
        {
            var closedViewModel = new ClosedVacancyViewModel();

            PopulateViewModelWithApplications(vacancy, closedViewModel);
            closedViewModel.ClosedDate = vacancy.ClosedDate.Value.AsGdsDate();
            return(new ViewVacancy
            {
                ViewModel = closedViewModel,
                ViewName = closedViewModel.HasApplications ? ViewNames.ManageClosedVacancyWithApplicationsView : ViewNames.ManageClosedVacancyView
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets vacancy for display without applications.
        /// </summary>
        /// <param name="vacancy"></param>
        /// <returns></returns>
        public async Task <DisplayVacancyViewModel> GetFullVacancyDisplayViewModelAsync(Vacancy vacancy)
        {
            var programme = await _client.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            switch (vacancy.Status)
            {
            case VacancyStatus.Approved:
                var approvedViewModel = new ApprovedVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(approvedViewModel, vacancy);

                approvedViewModel.ApprovedDate = vacancy.ApprovedDate.Value.AsGdsDate();
                return(approvedViewModel);

            case VacancyStatus.Live:
                var liveViewModel = new LiveVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(liveViewModel, vacancy);

                return(liveViewModel);

            case VacancyStatus.Closed:
                var closedViewModel = new ClosedVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(closedViewModel, vacancy);

                return(closedViewModel);

            case VacancyStatus.Submitted:
                var submittedViewModel = new SubmittedVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(submittedViewModel, vacancy);

                submittedViewModel.SubmittedDate = vacancy.SubmittedDate.Value.AsGdsDate();
                return(submittedViewModel);

            case VacancyStatus.Review:
                var reviewViewModel = new ReviewVacancyViewModel {
                    EducationLevelName = EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel)
                };
                await _vacancyDisplayMapper.MapFromVacancyAsync(reviewViewModel, vacancy);

                return(reviewViewModel);

            default:
                throw new InvalidStateException(string.Format(ErrorMessages.VacancyCannotBeViewed, vacancy.Title));
            }
        }