public async Task <LocationViewModel> GetLocationViewModelAsync( VacancyRouteModel vrm, VacancyEmployerInfoModel employerInfoModel, VacancyUser user) { var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_employerVacancyClient, _recruitVacancyClient, vrm, RouteNames.Location_Get); var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId != null ? employerInfoModel.AccountLegalEntityPublicHashedId : vacancy.AccountLegalEntityPublicHashedId; 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, accountLegalEntityPublicHashedId); var allLocations = await GetAllAvailableLocationsAsync(employerProfile); 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); }
private async Task UpdateEmployerProfileAsync(Vacancy vacancy, string employerDescription, VacancyUser user) { var employerProfile = await _vacancyClient.GetEmployerProfileAsync(vacancy.EmployerAccountId, vacancy.LegalEntityId); if (employerProfile == null) { throw new NullReferenceException($"No Employer Profile was found for employerAccount: {vacancy.EmployerAccountId}, legalEntity: {vacancy.LegalEntityId}"); } if (employerProfile.AboutOrganisation != employerDescription) { employerProfile.AboutOrganisation = employerDescription; await _vacancyClient.UpdateEmployerProfileAsync(employerProfile, user); } }
private async Task <Vacancy> MapDraftVacancyValues(CreateVacancyCommand request, Vacancy draftVacancyFromRequest, bool requiresEmployerReview) { var newVacancy = await _recruitVacancyClient.GetVacancyAsync(draftVacancyFromRequest.Id); draftVacancyFromRequest.VacancyReference = newVacancy.VacancyReference; draftVacancyFromRequest.TrainingProvider = request.Vacancy.TrainingProvider; draftVacancyFromRequest.CreatedByUser = newVacancy.CreatedByUser; draftVacancyFromRequest.CreatedDate = newVacancy.CreatedDate; draftVacancyFromRequest.OwnerType = newVacancy.OwnerType; draftVacancyFromRequest.SourceOrigin = newVacancy.SourceOrigin; draftVacancyFromRequest.SourceType = newVacancy.SourceType; var now = _timeProvider.Now; if (draftVacancyFromRequest.EmployerNameOption == EmployerNameOption.TradingName) { var employerProfile = await _recruitVacancyClient.GetEmployerProfileAsync( draftVacancyFromRequest.EmployerAccountId, draftVacancyFromRequest.AccountLegalEntityPublicHashedId); employerProfile.TradingName = draftVacancyFromRequest.EmployerName; await _recruitVacancyClient.UpdateEmployerProfileAsync(employerProfile, draftVacancyFromRequest.CreatedByUser); } if (requiresEmployerReview) { draftVacancyFromRequest.Status = VacancyStatus.Review; draftVacancyFromRequest.ReviewDate = now; draftVacancyFromRequest.ReviewByUser = request.VacancyUserDetails; draftVacancyFromRequest.ReviewByUser = request.VacancyUserDetails; draftVacancyFromRequest.ReviewCount += 1; } else { draftVacancyFromRequest.Status = VacancyStatus.Submitted; draftVacancyFromRequest.SubmittedDate = now; draftVacancyFromRequest.SubmittedByUser = request.VacancyUserDetails; } draftVacancyFromRequest.LastUpdatedDate = now; draftVacancyFromRequest.LastUpdatedByUser = request.VacancyUserDetails; return(draftVacancyFromRequest); }
public async Task <EmployerNameViewModel> GetEmployerNameViewModelAsync(VacancyRouteModel vrm, VacancyEmployerInfoModel employerInfoModel) { var vacancy = await _utility.GetAuthorisedVacancyForEditAsync(vrm, RouteNames.Employer_Get); var accountLegalEntityPublicHashedId = employerInfoModel?.AccountLegalEntityPublicHashedId ?? vacancy.AccountLegalEntityPublicHashedId; if (string.IsNullOrEmpty(accountLegalEntityPublicHashedId)) { return(null); } var getEmployerDataTask = _employerVacancyClient.GetEditVacancyInfoAsync(vrm.EmployerAccountId); var getEmployerProfileTask = _recruitVacancyClient.GetEmployerProfileAsync(vrm.EmployerAccountId, accountLegalEntityPublicHashedId); await Task.WhenAll(getEmployerDataTask, getEmployerProfileTask); var editVacancyInfo = getEmployerDataTask.Result; var employerProfile = getEmployerProfileTask.Result; var legalEntity = editVacancyInfo.LegalEntities.Single(l => l.AccountLegalEntityPublicHashedId == accountLegalEntityPublicHashedId); var vm = new EmployerNameViewModel { HasOnlyOneOrganisation = editVacancyInfo.LegalEntities.Count() == 1, LegalEntityName = legalEntity.Name, ExistingTradingName = employerProfile.TradingName, PageInfo = _utility.GetPartOnePageInfo(vacancy), SelectedEmployerIdentityOption = employerInfoModel?.EmployerIdentityOption ?? vacancy?.EmployerNameOption?.ConvertToModelOption(), NewTradingName = employerInfoModel?.NewTradingName, AnonymousName = employerInfoModel?.AnonymousName, AnonymousReason = employerInfoModel?.AnonymousReason ?? vacancy?.AnonymousReason, TaskListCompleted = _utility.TaskListCompleted(vacancy) }; if (vacancy.Status == VacancyStatus.Referred) { vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value, ReviewFieldMappingLookups.GetEmployerNameReviewFieldIndicators()); } 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); }