Exemplo n.º 1
0
        public async Task <TrainingViewModel> GetTrainingViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancyTask = Utility.GetAuthorisedVacancyForEditAsync(
                _client, _vacancyClient, vrm, RouteNames.Training_Get);
            var programmesTask = _client.GetActiveApprenticeshipProgrammesAsync();

            await Task.WhenAll(vacancyTask, programmesTask);

            var vacancy    = vacancyTask.Result;
            var programmes = programmesTask.Result;

            var vm = new TrainingViewModel
            {
                VacancyId           = vacancy.Id,
                SelectedProgrammeId = vacancy.ProgrammeId,
                Programmes          = programmes
                                      .Select(p =>
                                              new ApprenticeshipProgrammeViewModel
                {
                    Id   = p.Id,
                    Name = $"{p.Title}, Level: {p.Level}, level {(int)p.Level} ({p.ApprenticeshipType.ToString()})"
                }).OrderBy(p => p.Name),
                IsDisabilityConfident = vacancy.IsDisabilityConfident,
                PageInfo    = Utility.GetPartOnePageInfo(vacancy),
                CurrentYear = _timeProvider.Now.Year
            };

            if (vacancy.ClosingDate.HasValue)
            {
                vm.ClosingDay   = $"{vacancy.ClosingDate.Value.Day:00}";
                vm.ClosingMonth = $"{vacancy.ClosingDate.Value.Month:00}";
                vm.ClosingYear  = $"{vacancy.ClosingDate.Value.Year}";
            }

            if (vacancy.StartDate.HasValue)
            {
                vm.StartDay   = $"{vacancy.StartDate.Value.Day:00}";
                vm.StartMonth = $"{vacancy.StartDate.Value.Month:00}";
                vm.StartYear  = $"{vacancy.StartDate.Value.Year}";
            }

            // if (vacancy.Status == VacancyStatus.Referred)
            // {
            //     vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value,
            //         ReviewFieldMappingLookups.GetTrainingReviewFieldIndicators());
            // }

            return(vm);
        }