Exemple #1
0
        private async Task ValidateEmployerAccountIdAsync(long ukprn, string employerAccountId)
        {
            var providerInfo = await _providerVacancyClient.GetProviderEditVacancyInfoAsync(ukprn);

            if (providerInfo.Employers.Any(e => e.EmployerAccountId == employerAccountId) == false)
            {
                throw new AuthorisationException(string.Format(ExceptionMessages.ProviderEmployerAccountIdNotFound, ukprn, employerAccountId));
            }
        }
        private async Task <List <Address> > GetAllAvailableLocationsAsync(EmployerProfile employerProfile, Vacancy vacancy, long ukprn)
        {
            var providerData = await _providerVacancyClient.GetProviderEditVacancyInfoAsync(ukprn);

            var employerInfo = providerData.Employers.Single(e => e.EmployerAccountId == vacancy.EmployerAccountId);
            var legalEntity  = employerInfo.LegalEntities.First(l => l.LegalEntityId == employerProfile.LegalEntityId);
            var locations    = new List <Address>();

            locations.Add(legalEntity.Address.ConvertToDomainAddress());
            locations.AddRange(employerProfile.OtherLocations);
            return(locations);
        }
Exemple #3
0
        public async Task <EmployersViewModel> GetEmployersViewModelAsync(VacancyRouteModel vacancyRouteModel)
        {
            var editVacancyInfo = await _providerVacancyClient.GetProviderEditVacancyInfoAsync(vacancyRouteModel.Ukprn);

            var vm = new EmployersViewModel
            {
                PageInfo  = new PartOnePageInfoViewModel(),
                Employers = editVacancyInfo.Employers.Select(e => new EmployerViewModel {
                    Id = e.Id, Name = e.Name
                })
            };

            return(vm);
        }
Exemple #4
0
        public async Task <EmployersViewModel> GetEmployersViewModelAsync(VacancyRouteModel vrm)
        {
            var editVacancyInfo = await _providerVacancyClient.GetProviderEditVacancyInfoAsync(vrm.Ukprn);

            if (editVacancyInfo.Employers.Any() == false)
            {
                throw new MissingPermissionsException(string.Format(RecruitWebExceptionMessages.ProviderMissingPermission, vrm.Ukprn));
            }

            var vm = new EmployersViewModel
            {
                Employers = editVacancyInfo.Employers.Select(e => new EmployerViewModel {
                    Id = e.EmployerAccountId, Name = e.Name
                })
            };

            return(vm);
        }
        public async Task <EmployerNameViewModel> GetEmployerNameViewModelAsync(
            VacancyRouteModel vrm, VacancyEmployerInfoModel employerInfoModel, VacancyUser user)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(
                _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.EmployerName_Get);

            var accountLegalEntityPublicHashedId = employerInfoModel.AccountLegalEntityPublicHashedId;

            var getVacancyEditInfoTask = _providerVacancyClient.GetProviderEditVacancyInfoAsync(vrm.Ukprn);

            var getEmployerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, accountLegalEntityPublicHashedId);

            await Task.WhenAll(getVacancyEditInfoTask, getEmployerProfileTask);

            var employerInfo    = getVacancyEditInfoTask.Result.Employers.Single(e => e.EmployerAccountId == vacancy.EmployerAccountId);
            var employerProfile = getEmployerProfileTask.Result;

            var legalEntity = employerInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId);

            var vm = new EmployerNameViewModel
            {
                HasOnlyOneOrganisation = employerInfo.LegalEntities.Count() == 1,
                LegalEntityName        = legalEntity.Name,
                ExistingTradingName    = employerProfile?.TradingName,
                PageInfo = Utility.GetPartOnePageInfo(vacancy),
                SelectedEmployerIdentityOption = employerInfoModel.EmployerIdentityOption,
                NewTradingName  = employerInfoModel.NewTradingName,
                AnonymousName   = employerInfoModel.AnonymousName,
                AnonymousReason = employerInfoModel.AnonymousReason
            };

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

            return(vm);
        }
Exemple #6
0
        public async Task <bool> HasAgreementAsync(long ukprn)
        {
            var editVacancyInfo = await _client.GetProviderEditVacancyInfoAsync(ukprn);

            if (editVacancyInfo == null)
            {
                return(false);
            }

            if (editVacancyInfo.HasProviderAgreement)
            {
                return(true);
            }

            //Agreement may have been signed since the projection was created. Check PAS.
            var hasAgreement = await _pasAccountClient.HasAgreementAsync(ukprn);

            if (hasAgreement)
            {
                await _client.SetupProviderAsync(ukprn);
            }

            return(hasAgreement);
        }
Exemple #7
0
        private async Task <string> GetEmployerNameAsync(long ukprn, string employerId)
        {
            var providerInfo = await _providerVacancyClient.GetProviderEditVacancyInfoAsync(ukprn);

            return(providerInfo.Employers.FirstOrDefault(e => e.Id == employerId)?.Name);
        }