Exemplo n.º 1
0
        private async Task<string> GetEmployerTitleAsync(Vacancy vacancy)
        {
            if (vacancy.IsAnonymous)
                return vacancy.LegalEntityName;

            return await _vacancyClient.GetEmployerNameAsync(vacancy);
        }
        public async Task <OrchestratorResponse <SubmitVacancyResponse> > SubmitVacancyAsync(SubmitEditModel m, VacancyUser user)
        {
            var vacancy = await _utility.GetAuthorisedVacancyAsync(m, RouteNames.Preview_Submit_Post);

            if (!vacancy.CanSubmit)
            {
                throw new InvalidStateException(string.Format(ErrMsg.VacancyNotAvailableForEditing, vacancy.Title));
            }

            var employerDescriptionTask = _vacancyClient.GetEmployerDescriptionAsync(vacancy);
            var employerNameTask        = _vacancyClient.GetEmployerNameAsync(vacancy);

            await Task.WhenAll(employerDescriptionTask, employerNameTask);

            vacancy.EmployerDescription = employerDescriptionTask.Result;
            vacancy.EmployerName        = employerNameTask.Result;

            return(await ValidateAndExecute(
                       vacancy,
                       v => ValidateVacancy(v, SubmitValidationRules),
                       v => SubmitActionAsync(v, user)
                       ));
        }
Exemplo n.º 3
0
        public async Task MapFromVacancyAsync(DisplayVacancyViewModel vm, Vacancy vacancy)
        {
            var programme = await _vacancyClient.GetApprenticeshipProgrammeAsync(vacancy.ProgrammeId);

            var allQualifications = await _vacancyClient.GetCandidateQualificationsAsync();

            vm.ApplicationMethod       = vacancy.ApplicationMethod;
            vm.ApplicationInstructions = vacancy.ApplicationInstructions;
            vm.ApplicationUrl          = vacancy.ApplicationUrl;
            vm.CanDelete          = vacancy.CanDelete;
            vm.CanSubmit          = vacancy.CanSubmit;
            vm.ClosingDate        = (vacancy.ClosedDate ?? vacancy.ClosingDate)?.AsGdsDate();
            vm.EducationLevelName =
                EducationLevelNumberHelper.GetEducationLevelNameOrDefault(programme.EducationLevelNumber, programme.ApprenticeshipLevel);
            vm.EmployerDescription = vacancy.EmployerDescription;
            vm.EmployerName        = await _vacancyClient.GetEmployerNameAsync(vacancy);

            vm.EmployerWebsiteUrl       = vacancy.EmployerWebsiteUrl;
            vm.EmployerAddressElements  = Enumerable.Empty <string>();
            vm.FindAnApprenticeshipUrl  = _externalLinksConfiguration.FindAnApprenticeshipUrl;
            vm.IsAnonymous              = vacancy.IsAnonymous;
            vm.NumberOfPositions        = vacancy.NumberOfPositions?.ToString();
            vm.NumberOfPositionsCaption = vacancy.NumberOfPositions.HasValue
                ? $"{"position".ToQuantity(vacancy.NumberOfPositions.Value)} available"
                : null;
            vm.OutcomeDescription       = vacancy.OutcomeDescription;
            vm.PossibleStartDate        = vacancy.StartDate?.AsGdsDate();
            vm.ProviderContactName      = vacancy.ProviderContact?.Name;
            vm.ProviderContactEmail     = vacancy.ProviderContact?.Email;
            vm.ProviderContactTelephone = vacancy.ProviderContact?.Phone;
            vm.ProviderName             = vacancy.TrainingProvider?.Name;
            vm.Qualifications           = vacancy.Qualifications.SortQualifications(allQualifications).AsText();
            vm.ShortDescription         = vacancy.ShortDescription;
            vm.Skills                 = vacancy.Skills ?? Enumerable.Empty <string>();
            vm.ThingsToConsider       = vacancy.ThingsToConsider;
            vm.Title                  = vacancy.Title;
            vm.TrainingDescription    = vacancy.TrainingDescription;
            vm.VacancyDescription     = vacancy.Description;
            vm.VacancyReferenceNumber = vacancy.VacancyReference.HasValue
                                        ? $"VAC{vacancy.VacancyReference.ToString()}"
                                        : string.Empty;
            vm.IsDisabilityConfident = vacancy.IsDisabilityConfident;

            if (vacancy.EmployerLocation != null)
            {
                vm.MapUrl = MapImageHelper.GetEmployerLocationMapUrl(vacancy, _mapService, MapImageWidth, MapImageHeight);

                vm.EmployerAddressElements = vacancy.EmployerAddressForDisplay();
            }

            if (vacancy.ProgrammeId != null)
            {
                vm.TrainingTitle = programme?.Title;
                vm.TrainingType  = programme?.ApprenticeshipType.GetDisplayName();
                vm.TrainingLevel = programme?.ApprenticeshipLevel.GetDisplayName();
            }

            if (vacancy.Wage != null)
            {
                vm.ExpectedDuration = (vacancy.Wage.DurationUnit.HasValue && vacancy.Wage.Duration.HasValue)
                    ? vacancy.Wage.DurationUnit.Value.GetDisplayName().ToQuantity(vacancy.Wage.Duration.Value)
                    : null;
                vm.HoursPerWeek           = $"{vacancy.Wage.WeeklyHours:0.##}";
                vm.WageInfo               = vacancy.Wage.WageAdditionalInformation;
                vm.WageText               = vacancy.StartDate.HasValue ? vacancy.Wage.ToText(vacancy.StartDate) : null;
                vm.WorkingWeekDescription = vacancy.Wage.WorkingWeekDescription;
            }
        }