예제 #1
0
        public async Task <EmployerViewModel> GetEmployerViewModelAsync(VacancyRouteModel vrm)
        {
            var getEmployerDataTask = _client.GetEditVacancyInfoAsync(vrm.EmployerAccountId);
            var getVacancyTask      = Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Employer_Get);

            await Task.WhenAll(getEmployerDataTask, getVacancyTask);

            var employerData = getEmployerDataTask.Result;
            var vacancy      = getVacancyTask.Result;

            var vm = new EmployerViewModel
            {
                Organisations          = BuildLegalEntityViewModels(employerData, vrm.EmployerAccountId),
                SelectedOrganisationId = vacancy.LegalEntityId,
                PageInfo = Utility.GetPartOnePageInfo(vacancy)
            };

            if (vacancy.EmployerLocation != null)
            {
                vm.AddressLine1 = vacancy.EmployerLocation.AddressLine1;
                vm.AddressLine2 = vacancy.EmployerLocation.AddressLine2;
                vm.AddressLine3 = vacancy.EmployerLocation.AddressLine3;
                vm.AddressLine4 = vacancy.EmployerLocation.AddressLine4;
                vm.Postcode     = vacancy.EmployerLocation.Postcode;
            }
            else if (employerData.LegalEntities.Count() == 1 && vacancy.EmployerLocation == null)
            {
                var defaultLegalEntity = employerData.LegalEntities.First();
                vm.AddressLine1 = defaultLegalEntity.Address.AddressLine1;
                vm.AddressLine2 = defaultLegalEntity.Address.AddressLine2;
                vm.AddressLine3 = defaultLegalEntity.Address.AddressLine3;
                vm.AddressLine4 = defaultLegalEntity.Address.AddressLine4;
                vm.Postcode     = defaultLegalEntity.Address.Postcode;
            }

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

            return(vm);
        }