public async Task <LocationViewModel> GetLocationViewModelAsync( VacancyRouteModel vrm, VacancyEmployerInfoModel employerInfoModel, VacancyUser user) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync( _providerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Location_Get); var legalEntityId = employerInfoModel?.LegalEntityId ?? vacancy.LegalEntityId; var vm = new LocationViewModel(); vm.PageInfo = Utility.GetPartOnePageInfo(vacancy); vm.IsAnonymousVacancy = (employerInfoModel?.EmployerIdentityOption == null) ? vacancy.IsAnonymous : employerInfoModel.EmployerIdentityOption == EmployerIdentityOption.Anonymous; var employerProfile = await _recruitVacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, legalEntityId); var allLocations = await GetAllAvailableLocationsAsync(employerProfile, vacancy, vrm.Ukprn); vm.AvailableLocations = allLocations.Select(a => a.ToAddressString()).ToList(); var hasLegalEntityChanged = employerInfoModel?.HasLegalEntityChanged ?? false; if (vacancy.EmployerLocation != null && hasLegalEntityChanged == false) { var matchingAddress = GetMatchingAddress(vacancy.EmployerLocation.ToAddressString(), allLocations); if (matchingAddress == null) { vm.SelectedLocation = LocationViewModel.UseOtherLocationConst; vm.SetLocation(vacancy.EmployerLocation); } else { vm.SelectedLocation = matchingAddress.ToAddressString(); } } if (vacancy.Status == VacancyStatus.Referred) { vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value, ReviewFieldMappingLookups.GetLocationFieldIndicators()); } return(vm); }